setAxisScaleDiv - my scale div is invalid
I'm using my own logic to have customized ticks on my scale:
Code:
// mTimeScaleDiv is a AxisScaleDiv member
mTimeScaleDiv.invalidate();
mTimeScaleDiv.setInterval(0, 40000);
QList<double> majorTicks;
QList<double> minorTicks;
for (int i = 0; i < (20 + 1); i++)
{
if (i % 5 == 0)
{
majorTicks.append(i * 2000);
}
else
{
minorTicks.append(i * 2000);
}
}
mTimeScaleDiv.
setTicks(QwtScaleDiv::MajorTick, majorTicks
);
mTimeScaleDiv.
setTicks(QwtScaleDiv::MinorTick, minorTicks
);
// This returns false - why?
bool isValid = mTimeScaleDiv.isValid();
setAxisScaleDiv
(QwtPlot::xBottom, mTimeScaleDiv
);
Could anyone help me with an explanation why the scale div I'm creating is set to invalid?
Re: setAxisScaleDiv - my scale div is invalid
I resolved this using a different way to initialize, taken from from one of the samples:
Code:
QList<double>
&majorTicks
= ticks
[QwtScaleDiv::MajorTick];
QList<double>
&minorTicks
= ticks
[QwtScaleDiv::MinorTick];
for (int i = 0; i < (20 + 1); i++)
{
if (i % 5 == 0)
{
majorTicks.append(i * 2000);
}
else
{
minorTicks.append(i * 2000);
}
}
// mTimeScaleDiv is a AxisScaleDiv member
mTimeScaleDiv
= QwtScaleDiv(majorTicks.
first(), majorTicks.
last(), ticks
);
bool isValid = mTimeScaleDiv.isValid(); // For debug reasons
// Sets the updated plot
setAxisScaleDiv
(QwtPlot::xBottom, mTimeScaleDiv
);
Re: setAxisScaleDiv - my scale div is invalid
QwtScaleDiv::isValid() is used by the auto scaler inside of QwtPlot and has nothing to do with what everyone expects from the term "valid".
Of course this flag should be moved somewhere else with a better name.
Uwe
Re: setAxisScaleDiv - my scale div is invalid
Thank you for your reply.
My concern was not the flag itself, it was that I saw that while replotting, because of this invalid state my scale was generated automatically, and the ticks I defined were ignored. This happened with the first example of code I put in, but my resolved version doesn't have this problem.