updating Chart
-
Dear all
I have created a QT application (C++) which has a number of QCharts on a GridLayout (using ChartView).
This creation is done in a loop, During the creation, the number of layouts in the grid is not known, this is only known at the end of the loop and creation.In the charts I am using QLineSeries and QScatterSeries. This works quite well. However before the application is really. started I want to add some text in one of these chart.
I implemented this by mapping this on one of the points in the QScatterSeries (MaptoPosition). However at that moment the QChart.size is still unknown so mapping is impossible ?If the application is popped up and for instance I pressed a menu or toolbar, the Qchart.size is known and everything seems to work fine. So my question is the sequence of events that is generated during startup and at which point I the size of the Charts are known.
Another point is after every resize the mapping should be calculated again. How should I overrule the resize function of Qchart? Or is it possible the text positions automatically with the QChart (as the axis do). In fact I think this is the same as with a detached legend.
Kind regards - Jan Menssen
-
Dear all
I have created a QT application (C++) which has a number of QCharts on a GridLayout (using ChartView).
This creation is done in a loop, During the creation, the number of layouts in the grid is not known, this is only known at the end of the loop and creation.In the charts I am using QLineSeries and QScatterSeries. This works quite well. However before the application is really. started I want to add some text in one of these chart.
I implemented this by mapping this on one of the points in the QScatterSeries (MaptoPosition). However at that moment the QChart.size is still unknown so mapping is impossible ?If the application is popped up and for instance I pressed a menu or toolbar, the Qchart.size is known and everything seems to work fine. So my question is the sequence of events that is generated during startup and at which point I the size of the Charts are known.
Another point is after every resize the mapping should be calculated again. How should I overrule the resize function of Qchart? Or is it possible the text positions automatically with the QChart (as the axis do). In fact I think this is the same as with a detached legend.
Kind regards - Jan Menssen
@Jan-Menssen
Sizes are not known till widgets are rendered. Either overrideshowEvent()
orresizeEvent()
, or do your work fromQTimer::singleShot()
to give time for the widget to be shown. -
using a one shot timer works, thanks