QtChart with Qt designer
-
Hello,
I'm new in Qt. I would like to use QtChart with Qt designer but the QChart widget is not available from Qt designer.
After some research I found that I had to promote a widget to QChart. So I have the following in the Designer now
In the constructor I have the followingm_chart = ui->chartView->chart(); m_chartView = new QChartView(m_chart, this); m_xAxis = new QValueAxis; m_xAxis->setMax(1.0); m_xAxis->setMin(0.0); m_chart->addAxis(m_xAxis, Qt::AlignBottom); m_yAxis = new QValueAxis; m_yAxis->setMax(1.0); m_yAxis->setMin(0.0); m_chart->addAxis(m_yAxis, Qt::AlignLeft);
The result looks like that
What can I do to see the graph completele?
Thank you -
Hi
You are creating a new CharView which has default size so that what you are seeing.
you should use the one on the form
ui->chartView
and as @eyllanesc says delete the "new QChartView" line.Promotion is like a Type replacement, so Creator inserts the right type in the UI code
even in the fom its other type used a placeholder. -
Hi
You are creating a new CharView which has default size so that what you are seeing.
you should use the one on the form
ui->chartView
and as @eyllanesc says delete the "new QChartView" line.Promotion is like a Type replacement, so Creator inserts the right type in the UI code
even in the fom its other type used a placeholder. -
@Bert59
Hi
Well its quite some work to make a plugin pr platform and maintain it pr release.
Since QChart has many types of diagrams with its own properties, i guess
they simply didn't think it was worth it as it also has many helper classes and
would require a huge amount of code to be able to create such helper class
"live" and also set properties on that. Like axis and such.
https://doc.qt.io/qt-5/qtcharts-module.htmlAlso it is using Qt Graphics View Framework and it does not use the same virtual system as QWidgets so
that would also need to be added to the editor.But I'm just guessing :)
Could be any reason but for Graphics View Framework, you must also set the scene in code and
The designer cannot be used to set any properties of its items.So Maybe QChart just inherited that and providing Designer option for that is just very complicated bordering
to impossible without heavy assumptions on behalf of the user. -
@Bert59 If you want to use QChartView in Qt Designer without the promotion then you must compile and install the plugin, in this post I show the procedure: https://stackoverflow.com/questions/48362864/how-to-insert-qchartview-in-form-with-qt-designer/48363007#48363007
-
@Bert59
Hi
In chrome, you can use right clickOr you can go to front page
https://github.com/qt/qtcharts.git
and press the big green download.and then take the files from the zip directly.