Results 1 to 4 of 4

Thread: Qwt, Align content to center

  1. #1
    Join Date
    Jun 2014
    Posts
    8
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android
    Thanks
    3

    Default Qwt, Align content to center

    Hello everyone,
    My question is, how to locate the content of QwtPlot in the center? Normaly after axisAutoscale, content pushed to left-bottom corner, and end of scale setted at nearest bigger division after end on contet, so it already lookn not in the middle. Also, I use rescaler by Y-axis to keep equal-scale and make content looks in real scale. In this case, my content can occupy whole range of Y-axis, but only half of X-axis, and it will still pushed to leftBottom corner (pictures take left half of QwtPlot, and right side is empty), look not good. Is awailable to set align-center content of plot by x-axis, or for both axises?
    If describtion is not clear, I can attach pictures for example.
    Sorry if question is lame, I didnt found usefull info at internet.
    I would appreciate any help.

  2. #2
    Join Date
    Jun 2014
    Posts
    8
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android
    Thanks
    3

    Default Re: Qwt, Align content to center

    I will try show what I looking for.
    Like that I have now, with QwtPlotRescaler/axisAutoScale
    pic1.jpg
    And like that I wants to get automaticaly:
    pic2.jpg
    Is it generaly possible?

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,326
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 880 Times in 828 Posts

    Default Re: Qwt, Align content to center

    Isn't your question about how to configure the auto scaler to adjust the scale being symmetric according to the center of the given range ?

    Maybe setting the QwtScaleEngine::Floating flag is already good enough - if not you can try the code below:

    Qt Code:
    1. class MyScaleEngine: public QwtLinearScaleEngine
    2. {
    3. public:
    4. MyScaleEngine()
    5. {
    6. setAttribute( QwtScaleEngine::Symmetric, true );
    7. }
    8.  
    9. virtual void autoScale( int maxNumSteps, double &x1, double &x2, double &stepSize ) const
    10. {
    11. MyScaleEngine *that = const_cast<MyScaleEngine *>( this );
    12. that->setReference( 0.5 * ( x1 + x2 ) );
    13.  
    14. QwtLinearScaleEngine::autoScale( maxNumSteps, x1, x2, stepSize );
    15. }
    16. };
    To copy to clipboard, switch view to plain text mode 
    Uwe

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

    Asting (18th June 2014)

  5. #4
    Join Date
    Jun 2014
    Posts
    8
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android
    Thanks
    3

    Default Re: Qwt, Align content to center

    Thanks for advice Uwe. Tip about "floating" flag was very usefull. Unfortunately the proposed class did not work in my case
    But suddenly, I found solution in QwtPlotRescaler::setExpandingDirection(axisID, QwtPlotRescaler::ExpandBoth);

Similar Threads

  1. Replies: 3
    Last Post: 20th February 2014, 16:14
  2. Align two rects
    By jesse_mark in forum Newbie
    Replies: 1
    Last Post: 14th June 2013, 17:29
  3. Align QDialog
    By sousadaniel7 in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2012, 19:39
  4. Replies: 2
    Last Post: 23rd February 2010, 08:52
  5. How to align list items to the center?
    By zgulser in forum Qt Tools
    Replies: 4
    Last Post: 9th February 2009, 10:52

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