Results 1 to 2 of 2

Thread: Zoom and pan with two y-axes

  1. #1
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Zoom and pan with two y-axes

    Hello,
    I've seen a lot of questions about QwtPlotZoomer already that are related to my question. I combined some of the hints from the answers, but still haven't worked it out, yet.

    We have a QwtPlot with two y axes (showing different units) and one x -axis. We want to zoom and pan over the x and both y axes. I've copied the source code for the ScrollZoomer from the "realtime_plot" example to get zoom and pan working. Then I looked at the "bode" example to get zooming work for two axes, by adding a second QwtPlotZoomer for the right y-axis. Now, the zooming seems to work for the left y-axis and the right scale also responds to the zooming. But, when scrolling the vertical scrollbar, the window only pans for the left axis, not the right. Also the zoom area doesn't seem to completely be the area that I zoomed in on.
    I assume, because the scrollbars are only connected to the left y-axis. So somehow the scrollbars have to synchronize the left and right y-axis. And maybe because both axes have different scales, they interfere with each other.

    Am I on the right path by installing a second QwtPlotZoomer for the right y-axis? Or should I stay with one ScrollZoomer and modify it to synchronize the two y-axes? Or even use two ScrollZoomers for both axes that share the same scrollbars?

    Thanks,
    Michiel

  2. #2
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Zoom and pan with two y-axes

    Hi Michiel,

    I had the same problem and found a very simple solution:

    Qt Code:
    1. connect(zoomer1, SIGNAL(zoomed(const QwtDoubleRect &)), zoomer2, SLOT(zoom(const QwtDoubleRect &)) );
    To copy to clipboard, switch view to plain text mode 
    since the "zoomed" signal is also emitted when you move the scrollbars, the second zoomer always gets synchronized

    Felix

Similar Threads

  1. QWTPlot Zoom: cannot zoom negative value
    By jwieland in forum Qwt
    Replies: 0
    Last Post: 8th January 2010, 17:16
  2. Plot Axes
    By mcarter in forum Qwt
    Replies: 0
    Last Post: 5th December 2009, 00:47
  3. Replies: 1
    Last Post: 16th November 2009, 06:25
  4. Default axes after calling zoom(0)
    By Paladin12 in forum Qwt
    Replies: 3
    Last Post: 9th December 2008, 00:40
  5. QGLWidget with text - zoom in / zoom out
    By h123 in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2008, 10:56

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.