How does works QwtScaleDraw::extent()?
why if I call extent() from a QwtScaleDraw object the result is less then if I call from QwtScaleWidget::scaleDraw()?
what do I need to setup in QwtScaleDraw object to make extent() return the sam as QwtScaleWidget::scaleDraw().extent()?
her is the code snippet:
Code:
// code to test extent() method
QList< double > ld;
double q;
for(q=-60.0; q<=0.0; q+=5.0)
ld.append(q);
sdraw->setScaleDiv(*sd);
qDebug("extent 1 %f", sdraw->extent(f)); // here is 23.0
w->setScaleDiv(*sd);
qDebug("extent 2 %f", w->scaleDraw()->extent(f)); // here is 31.0
bets regards
max
Re: How does works QwtScaleDraw::extent()?
Different fonts, different sizes.
Uwe
Re: How does works QwtScaleDraw::extent()?
why do you say "different font"?
I pass the same font to extent() calls: look at lines 16 and 21.
If it uses another font to calculate extent why to pass font as parameter, and how to set the font in QwtScaleDraw?
best regards
max
Re: How does works QwtScaleDraw::extent()?
Quote:
Originally Posted by
mastupristi
I pass the same font to extent() calls: look at lines 16 and 21.
True, but anyway: Qwt is open source, why not simply checking the code.
Uwe
Re: How does works QwtScaleDraw::extent()?
that's right.
browsing the code I can see that the problem is the orientation, and if I set the right orientation the value are the same:
Code:
//
QList< double > ld;
double q;
for(q=-60.0; q<=0.0; q+=5.0)
ld.append(q);
w->setScaleDiv(*sd);
qDebug("orient w %d", w->scaleDraw()->orientation()); // here is Qt::Vertical
qDebug("extent 2 %f", w->scaleDraw()->extent(w->font())); // is 31.0
sdraw->setScaleDiv(*sd);
qDebug("orient sdraw %d", sdraw->orientation()); // here is Qt:Horizontal
sdraw
->setAlignment
(QwtScaleDraw::LeftScale);
// Change to vertical
qDebug("extent 1 %f", sdraw->extent(w->font())); // here is also 31.0
best regards
max