Results 1 to 4 of 4

Thread: Problem while handling QwtPlotZoomer with right mouse button

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

    Default Problem while handling QwtPlotZoomer with right mouse button

    Hi All,

    For my application i have to enable the zoom mode when both the mouse buttons are pressed and zoom the selected the region when both mouse buttons are held together and dragged.I am able to zoom it with the both buttons.But it is also working with only left button.I want the zoom feature only when both the buttons are pressed.How can i disable it with the left mouse button.

    refer to my code:

    constructor:
    m_ptrZoomer = new QwtPlotZoomer(plot()->xBottom,plot()->yLeft,plot()->canvas());
    m_ptrPanner = new QwtPlotPanner(plot()->canvas());
    m_ptrPicker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
    QwtPicker::RectSelection | QwtPicker:: DragSelection,QwtPicker::RectRubberBand, QwtPicker::ActiveOnly,plot()->canvas());
    m_ptrZoomer->setMousePattern((QwtEventPattern::MouseSelect2,Qt ::RightButton,Qt::ControlModifier);

    QMousePressEvent:

    m_ptrZoomer->setEnabled(true);
    m_ptrPanner->setEnabled(true);
    m_ptrPicker->setEnabled(true);

    thanks,

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

    Default Re: Problem while handling QwtPlotZoomer with right mouse button

    This doesn't fit into the concept of the state machine of a picker, that handles single mouse buttons in combination with the keyboard modifiers only. So you have to fool the picker.

    Configure your zoomer for using the left mouse button ( = default ) and reimplement QwtZoomer::widgetMousePressEvent like this (untested):

    Qt Code:
    1. virtual void YourZoomer::widgetMousePressEvent(QMouseEvent *e)
    2. {
    3. if ( ( e->button() == Qt::LeftButton || e->button() == Qt::RightButton )
    4. && (e->buttons() == Qt::LeftButton | Qt::RightButton) )
    5. {
    6. QMouseEvent me(e->type(), e->pos(),
    7. Qt::LeftButton, Qt::NoButton, Qt::NoModifier );
    8. QwtPlotZoomer::widgetMousePressEvent(&me);
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    Uwe

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

    Default Re: Problem while handling QwtPlotZoomer with right mouse button

    I tried this code but still i am getting the same result.I reimplemented widgetMousePressEvent,But the Zoomer is still working for the Left button.I need it when both the buttons are clicked simultaneously not with the single button.

    Can you suggest me in the other way or be more clear.

    Thanks and Regards,

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

    Default Re: Problem while handling QwtPlotZoomer with right mouse button

    Start the debugger, set a breakpoint in YourZoomer::widgetMousePressEvent and check, why the left button is not blocked.

    Uwe

Similar Threads

  1. QSlider and right mouse button
    By Abnormalia in forum Qt Programming
    Replies: 4
    Last Post: 17th March 2009, 13:13
  2. Problem with QwtPlotZoomer
    By seguprasad in forum Qt Programming
    Replies: 1
    Last Post: 21st November 2007, 09:31
  3. Mouse Over event on button
    By vishal.chauhan in forum Qt Programming
    Replies: 9
    Last Post: 10th January 2007, 06:03

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.