1 pièce(s) jointe(s)
Insertion d'un QChartView dans un QGraphicsView
Bonjour.
J'ai créé dans Qt designer un objet QGraphicsView, que j'ai appelé "chart" et promu en QChartView :
Pièce jointe 593973
Je souhaite, à partir de mon code, y insérer un QChart. Pour cela, j'ai créé une fonction dans mainwindow:
Code:
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 :
Citation:
no matching function for call to ‘QChartView(QObject*)
dans qobject.h ou encore :
Citation:
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:
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.