QValueAxis::setTickInterval() has no effect
-
Dear Forum,
I Have a QChart with some QLineSeries all attached to the same X and Y axis. However, the scaling of the axes is very weird; Qt always divides the complete range by four and sets that as tick interval. Since my range is some odd number, I end up with crooked tick intervals. I tried to set the tick interval myself; however, that had no effect.
My code is
QValueAxis *xAxis = new QValueAxis(this); QValueAxis *yAxis = new QValueAxis(this); xAxis->setRange(0, maxX()); yAxis->setRange(0, maxY()); addAxis(xAxis, Qt::AlignBottom); addAxis(yAxis, Qt::AlignLeft); xAxis->setTickInterval(unit(maxX(), NTICKS)); yAxis->setTickInterval(unit(maxY(), NTICKS));
The axis is still shown with crooked tick intervals. I expect that the axis shows tick intervals as I set them.
I am using Qt6.
Best
Stephan
-
I found the answer myself, you have to specify dynamic ticks.
xAxis->setTickType(QValueAxis::TicksDynamic); yAxis->setTickType(QValueAxis::TicksDynamic);
Now it works.