Results 1 to 5 of 5

Thread: Constant Grid

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: Constant Grid

    I Set the stepsize to 10...

    But, whe I zoom everything changed again

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

    Default Re: Constant Grid

    Quote Originally Posted by myzinsky View Post
    But, whe I zoom everything changed again
    Setting a fixed step size doesn't make too much sense when zooming ( consider a step size of 10 for a range of 5-6 ).

    But as I wrote before - simply decouple the grid from the ticks of the scales by overloading QwtPlotGrid::updateScaleDiv().

    Qt Code:
    1. class YourGrid: public QwtPlotGrid
    2. {
    3. public:
    4. ...
    5. virtual void updateScaleDiv( const QwtScaleDiv& xScaleDiv, const QwtScaleDiv& yScaleDiv )
    6. {
    7. QwtScaleDiv scaleDiv;
    8. scaleDiv.setInterval( xScaleDiv.interval() );
    9.  
    10. double min = xScaleDiv.interval().lowerBound();
    11. double max = xScaleDiv.interval.upperBound();
    12. if ( min > max )
    13. qSwap( min, max );
    14.  
    15. const int stepSize = 10.0;
    16.  
    17. min = static_cast<int>( min / stepSize ) * stepSize;
    18.  
    19. QList<double > ticks;
    20. for ( double tick = min; tick <= max; tick += stepSize )
    21. ticks += tick;
    22.  
    23. scaleDiv.setTicks( QwtScaleDiv::MajorTick, ticks );
    24.  
    25. QwtPlotGrid::updateScaleDiv( scaleDiv, yScaleDiv );
    26. }
    To copy to clipboard, switch view to plain text mode 

    Uwe

  3. #3

    Default Re: Constant Grid

    It works fine!

    But I had to change this:

    Qt Code:
    1. double min = xScaleDiv.interval().minValue();
    2. double max = xScaleDiv.interval().maxValue();
    To copy to clipboard, switch view to plain text mode 

    Tank You Uwe!
    Regards

Similar Threads

  1. yLeft axis constant width
    By baray98 in forum Qwt
    Replies: 4
    Last Post: 4th January 2013, 16:40
  2. Replies: 2
    Last Post: 9th March 2011, 12:27
  3. how to compare a Qstring with a constant char*
    By qt_user in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2010, 03:42
  4. Constant busy cursor when application is run
    By b1 in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 10th January 2010, 21:30
  5. QTableView has constant number of rows
    By tomeks in forum Qt Programming
    Replies: 5
    Last Post: 10th December 2008, 15:29

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
  •  
Qt is a trademark of The Qt Company.