Insert QchartView into a QGraphicsView.
-
Hi,
I created a QGraphicsView in QtDesigner, that I have called "chart" and promoted in QChartView :
I wanna give him a chart from my main function.. For that, I created a function in mainwindow:
void MainWindow::addChart(QChart * chart){ this->centralWidget()->findChild<QChartView>("chart").setRenderHint(QPainter::Antialiasing); this->centralWidget()->findChild<QChartView>("chart").setChart(chart); }
I call this function correctly in the main: :
MainWindow w; QChart *chart = new QChart(); // ... w.addChart(chart);
However, the IDE accept it but when I start the compilation, this code dosen't compile. It returns errors like : no matching function for call to ‘QChartView(QObject*) dans qobject.h
or : could not convert ‘qt_qFindChild_helper(((const QObject*)this), (* & aName), QtCharts::QChartView::staticMetaObject, options)’ from ‘QObject*’ to ‘const QtCharts::QChartView&’Is it a promotion error of the QGraphicsView ? Or maybe I should do something in the .pro file ? Or is there a more simple method to do that ?
Thank you for your help.
-
Hi
If you added the view in Design mode and promoted it, it should be accessible via
ui->chart.So no need to find it again with findChild