Results 1 to 2 of 2

Thread: QwtScaleDraw/Widget: Minor Ticks and Step Sizes

  1. #1
    Join Date
    Sep 2007
    Posts
    61
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QwtScaleDraw/Widget: Minor Ticks and Step Sizes

    I have three questions regarding the QwtScaleDraw:

    1) Is there a way to label a minor tick?
    2) Is there a way to get the current step size from QwtScaleDraw?
    3) When I set the step size of the scale engine to something large, my plot is significantly larger than if I go by the defaults. I reason that this is due to the the Qwt plot canvas size being determined by how large the scale is. Is that right? How do I make it keep the usual size it calculates with the defaults, but still have a different number of labels?

    I am overriding the QwtScaleDraw with my own stuff, but I am using the standard QwtScaleWidget.

    Thanks,
    Joey

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

    Default Re: QwtScaleDraw/Widget: Minor Ticks and Step Sizes

    Is there a way to label a minor tick?
    You might have layout issues, but beside this you can do the following:

    Qt Code:
    1. virtual void YourScaleDraw::draw( QPainter *painter,
    2. const QPalette& palette ) const
    3. {
    4. painter->setPen( palette.color( QPalette::Text ) );
    5.  
    6. const QList<double> ticks = scldiv().ticks( QwtScaleDiv::MinorTick );
    7. for ( int i = 0; i < ticks.count(); i++ )
    8. {
    9. const double v = ticks[i];
    10. if ( d_data->scldiv.contains( v ) )
    11. drawLabel( painter, v );
    12. }
    13.  
    14. QwtScaleDraw::draw( painter, palette );
    15. }
    To copy to clipboard, switch view to plain text mode 

    Is there a way to get the current step size from QwtScaleDraw?
    The step size is a parameter that is used for calculating the boundaries and ticks ( QwtScaleDiv ) of a scale, but the scale division might be built manually as well. So a QwtScaleDraw object has no step size !

    But when a scale division has been calculated from a scale engine then delta between 2 major steps is usually the value you are looking for. Note, that when you have used a step size of 0 the step size has been calculated using the max major steps parameter instead.

    When I set the step size of the scale engine to something large, my plot is significantly larger than if I go by the defaults.
    No it isn't - the only effect I can imagine is because the scales are somehow aligned ( depending on the flags of the scale engine ) to multiples of the step size. But this leads to different ticks and boundaries, but not to larger scales.

    Larger scales ( in widget coordinates ) might be because of having many major steps and tick labels, where space is needed.

    HTH,
    Uwe

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

    bigjoeystud (19th September 2012)

Similar Threads

  1. Replies: 4
    Last Post: 23rd July 2012, 20:09
  2. Qt Creator Debugging step by step through else rich code does not work
    By Terjoqu in forum Qt Tools
    Replies: 1
    Last Post: 11th March 2010, 21:44
  3. learn how to install QT with msvc2005 step by step
    By coder1985 in forum Installation and Deployment
    Replies: 6
    Last Post: 20th December 2007, 19:56
  4. Video Tutorials or step by step guides?
    By Dumbledore in forum Newbie
    Replies: 2
    Last Post: 10th October 2007, 08:33
  5. Step by Step MySQL Plugin... what's next step?
    By chaosgeorge in forum Qt Programming
    Replies: 20
    Last Post: 5th November 2006, 15:32

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.