Bonjour.
J'ai créé dans Qt designer un objet QGraphicsView, que j'ai appelé "chart" et promu en QChartView :
Nom : promotion.png
Affichages : 667
Taille : 48,3 Ko

Je souhaite, à partir de mon code, y insérer un QChart. Pour cela, j'ai créé une fonction dans mainwindow:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
void MainWindow::addChart(QChart * chart){
    this->centralWidget()->findChild<QChartView>("chart").setRenderHint(QPainter::Antialiasing);
    this->centralWidget()->findChild<QChartView>("chart").setChart(chart);
}
Cependant, ce code ne compile pas. J'obtiens des erreurs du type :
no matching function for call to ‘QChartView(QObject*)
dans qobject.h ou encore :
could not convert ‘qt_qFindChild_helper(((const QObject*)this), (* & aName), QtCharts::QChartView::staticMetaObject, options)’ from ‘QObject*’ to ‘const QtCharts::QChartView&’
J'appelle pourtant correctement cette fonction, dans le main :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
MainWindow w;
QChart *chart = new QChart();
// ...
 w.addChart(chart);
S'agit-il d'une erreur lors de la promotion du QGraphicsView ? Y a t-il quelque chose à modifier dans le .pro ? Y a-t-il une manière plus simple de faire cela ?

Merci pour votre aide.