PDA

View Full Version : How to disable QwtPlotMagnifier right click



jmsbc
21st August 2009, 23:12
Hi,

When I use QwtPlotMagnifier for zooming, it assigns the right mouse button for zooming in and out when u hold right mouse button and move up/down. How do I disable this so that I can use it for the QwtPlotZoomer rubberband? Thank you.

-James

Uwe
25th August 2009, 15:14
http://qwt.sourceforge.net/class_qwt_magnifier.html#345e4f61d48274f73f6e39fdc aea6745

Uwe

jmsbc
25th August 2009, 17:36
Thanks Uwe,

The solution is to do:

mMagnify->setMouseButton(QwtEventPattern::MouseSelect6, Qt::NoButton);

I didn't realize that MouseSelect6 was the one I need to set, thanks

Uwe
25th August 2009, 22:35
I didn't realize that MouseSelect6 was the one I need to set, thanksNo, QwtEventPattern::MousePatternCode has absolutely nothing to do with the parameter you have to set in QwtMagnifier::setMouseButton. MouseSelect6 is simply the 6th enum value and is mapped to 5 by the compiler, what might be a value, that does what you want - but this by accident and passing the 6th value of any other enum (or a blank 5 ) would have the same effect.

The values you have to use are those you find in a QMouseEvent:



void QwtMagnifier::setMouseButton(int button, int buttonState)
{
d_data->mouseButton = button;
d_data->mouseButtonState = buttonState;
}

void QwtMagnifier::widgetMousePressEvent(QMouseEvent *me)
{
if ( me->button() != d_data->mouseButton || parentWidget() == NULL )
return;

if ( (me->modifiers() & Qt::KeyboardModifierMask) !=
(int)(d_data->mouseButtonState & Qt::KeyboardModifierMask) )
{
return;
}

...
}

Uwe