PDA

View Full Version : Problem while handling QwtPlotZoomer with right mouse button



seguprasad
28th November 2007, 06:31
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,

Uwe
28th November 2007, 08:24
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):


virtual void YourZoomer::widgetMousePressEvent(QMouseEvent *e)
{
if ( ( e->button() == Qt::LeftButton || e->button() == Qt::RightButton )
&& (e->buttons() == Qt::LeftButton | Qt::RightButton) )
{
QMouseEvent me(e->type(), e->pos(),
Qt::LeftButton, Qt::NoButton, Qt::NoModifier );
QwtPlotZoomer::widgetMousePressEvent(&me);
}
}

Uwe

seguprasad
3rd December 2007, 10:05
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,

Uwe
4th December 2007, 10:04
Start the debugger, set a breakpoint in YourZoomer::widgetMousePressEvent and check, why the left button is not blocked.

Uwe