Solved Custom QtChart promote
-
I want to connect "QtChart" to "Custom widget".
I downloaded the file in the path below.
https://doc.qt.io/qt-5.12/qtcharts-zoomlinechart-example.htmlAnd I created a widget in my project and set "promote" as follows.
Base class name: QWidget
Promoted class name : ChartView
Header file: chartview.h
global include : uncheckedbut the result is a debugging error
ui_mainwindow.h
chartWidget = new ChartView(gBoxChart);The parameters of ChartView are created strangely.
It seems to be affected by the ui's widget's parent.I modified ui_mainwindow.h myself, but when I rebuild it, it goes back to the old state.
chartWidget = new ChartView(chart);
I want to edit it, but it doesn't work.What did I do wrong?
Thank you for reading my poor English. -
Neither - create a ctor which takes
QWidget *parent
like the base class does: https://doc.qt.io/qt-5/qchartview.html#QChartView -
@LISP said in Custom QtChart promote:
I modified ui_mainwindow.h myself, but when I rebuild it, it goes back to the old state.
Because you dont need to nor should modify it yourself.
but the result is a debugging error
What error exactly?
-
Thank you for your reply.
ui_mainwindow.h
chartWidget = new ChartView(gBoxChart); ////This code is an error.
error : no matching function for call to 'ChartView::ChartView(QGroupBox*&) in file included from ...I don't think chartview can have gboxChart as a parameter.
So I modified the ui_mainwindow.h myself.
However, it is an auto-generated code, so when it is build, it is restored as it's original state. -
You must modify your ChartView so it takes the QWidget parent as first parameter. Otherwise uic can not generate the code for it.
-
@Christian-Ehrlicher
Thanks for the good info.
try one thing or another...
ChartView(QChart *chart, QWidget *parent = 0);
-> ChartView(QWidget *parent = 0, QChart *chart); ?
Sorry.. :'( -
Neither - create a ctor which takes
QWidget *parent
like the base class does: https://doc.qt.io/qt-5/qchartview.html#QChartView