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,
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):
Code:
virtual void YourZoomer
::widgetMousePressEvent(QMouseEvent *e
) {
if ( ( e->button() == Qt::LeftButton || e->button() == Qt::RightButton )
&& (e->buttons() == Qt::LeftButton | Qt::RightButton) )
{
Qt::LeftButton, Qt::NoButton, Qt::NoModifier );
}
}
Uwe
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,
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