Results 1 to 4 of 4

Thread: How to get vertical/horizontal zoom box?

  1. #1
    Join Date
    Mar 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to get vertical/horizontal zoom box?

    I'm using QwtPlot with a zoomer and panner and everything is fine. But the users would like to be able to optionally constrain the box zoom to be horizontal or vertical. In other words, they would like to hold down shift while dragging the mouse and have the top y position of the zoom box be fixed at 0 and the bottom y position fixed at the bottom of the canvas. The x range of the box would be as normal. The drawn rubber band rectangle should also reflect this. Similarly, when Ctrl is held down while dragging the mouse, the box would stretch in x from 0 to the canvas width. I see in QwtPicker that there is a HLineRubberBand and VLineRubberBand which sound like what I want but I can't seem to get them to work like I expect. I also have no idea how to hook them up to the shift/ctrl key modifiers for the mouse drag events.

    Has anyone done something like this? Is there an easy way to do it other than hacking drawRubberBand()?
    Thanks.

  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: How to get vertical/horizontal zoom box?

    Obviously you are looking for a picker selecting a point ( not a zoomer selecting a rectangle ) Look at the bode example: if you don't enable the Zoom Button an picker is active showing a crosshair ( QwtPicker::CrossRubberBand ). Instead you can also have a QwtPicker::HLineRubberBand or QwtPicker::VLineRubberBand.

    QwtPicker is derived from QwtEventPattern. Read the docs how to change the mouse/key events, that trigger the selection of your picker.

    Uwe

  3. #3
    Join Date
    Mar 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to get vertical/horizontal zoom box?

    I'm sorry if that's not so obvious to me. The user wants to click and drag a zoom region (that might have a max vertical or horizontal extent depending on the modifier). That sure sounds like a rectangle selection to me and not a point selection, but maybe I'm not understanding what a point selection means. The picker in the bode example doesn't look like what I'm after because it isn't zooming on a region selected by the user.

    I have read the docs on mouse/key events but I have found nothing that describes how to add a shift modifier to the mouse drag event and how to hook in code that will make the rectangle maximize in vertical or horizontal directions. I tried implementing widgetMouseMoveEvent in my zoomer (which derives from QwtPlotZoomer). I can get the modifier and have tried creating a new event based on the original one but with changed position and no modifier and then I call QwtPlotZoomer::widgetMouseMoveEvent(event). But this doesn't work. Even if all I do is create a copy of the event (using the copy constructor), it still doesn't work, so obviously there is something in the event that isn't getting copied.

    Thanks.

  4. #4
    Join Date
    Apr 2008
    Location
    China
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get vertical/horizontal zoom box?

    Have a look at this: http://qwt.sourceforge.net/class_qwt...d41a4c0285d1ea the MouseSelect4 is Qt::LeftButton + Qt::ShiftButton. It's maybe what you want.

Similar Threads

  1. Replies: 1
    Last Post: 16th November 2009, 05:25
  2. QGraphicsItem Horizontal/Vertical move only
    By prashant in forum Qt Programming
    Replies: 2
    Last Post: 9th November 2009, 09:02
  3. Vertical scroll bar, but resizable horizontal content
    By minimoog in forum Qt Programming
    Replies: 0
    Last Post: 14th January 2009, 20:51
  4. QGLWidget with text - zoom in / zoom out
    By h123 in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2008, 09:56
  5. Replies: 4
    Last Post: 27th September 2006, 13:34

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.