Results 1 to 5 of 5

Thread: How does works QwtScaleDraw::extent()?

  1. #1
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question 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:
    Qt Code:
    1. // code to test extent() method
    2.  
    3. QFont f;
    4.  
    5. QwtScaleDiv *sd = new QwtScaleDiv(-60, 0);
    6. QList< double > ld;
    7.  
    8. double q;
    9. for(q=-60.0; q<=0.0; q+=5.0)
    10. ld.append(q);
    11.  
    12. sd->setTicks(QwtScaleDiv::MajorTick, ld);
    13.  
    14. QwtScaleDraw *sdraw = new QwtScaleDraw;
    15. sdraw->setScaleDiv(*sd);
    16. qDebug("extent 1 %f", sdraw->extent(f)); // here is 23.0
    17.  
    18. w->setScaleDiv(*sd);
    19.  
    20. qDebug("extent 2 %f", w->scaleDraw()->extent(f)); // here is 31.0
    To copy to clipboard, switch view to plain text mode 

    bets regards
    max

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How does works QwtScaleDraw::extent()?

    Different fonts, different sizes.

    Uwe

  3. #3
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How does works QwtScaleDraw::extent()?

    Quote Originally Posted by mastupristi View Post
    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

  5. The following user says thank you to Uwe for this useful post:

    mastupristi (10th May 2016)

  6. #5
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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:
    Qt Code:
    1. //
    2. QwtScaleDiv *sd = new QwtScaleDiv(-60, 0);
    3. QList< double > ld;
    4.  
    5. double q;
    6. for(q=-60.0; q<=0.0; q+=5.0)
    7. ld.append(q);
    8.  
    9. sd->setTicks(QwtScaleDiv::MajorTick, ld);
    10.  
    11. w->setScaleDiv(*sd);
    12.  
    13. qDebug("orient w %d", w->scaleDraw()->orientation()); // here is Qt::Vertical
    14. qDebug("extent 2 %f", w->scaleDraw()->extent(w->font())); // is 31.0
    15.  
    16. QwtScaleDraw *sdraw = new QwtScaleDraw;
    17. sdraw->setScaleDiv(*sd);
    18. qDebug("orient sdraw %d", sdraw->orientation()); // here is Qt:Horizontal
    19. sdraw->setAlignment(QwtScaleDraw::LeftScale); // Change to vertical
    20.  
    21. qDebug("extent 1 %f", sdraw->extent(w->font())); // here is also 31.0
    To copy to clipboard, switch view to plain text mode 

    best regards
    max

Similar Threads

  1. QwtScaleDraw for yaxis
    By mikrocat in forum Qwt
    Replies: 6
    Last Post: 25th January 2016, 07:54
  2. Replies: 2
    Last Post: 27th August 2014, 12:31
  3. LayoutDirectoin of QwtScaleDraw
    By jesse_mark in forum Qwt
    Replies: 1
    Last Post: 2nd November 2012, 08:31
  4. Replies: 3
    Last Post: 6th July 2011, 07:59
  5. Replies: 1
    Last Post: 14th October 2010, 19:56

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.