[Qt-interest] WheelEvent propagation
Oliver Demetz
forenbeitraege at oliverdemetz.de
Wed Aug 19 17:29:33 CEST 2009
Hi,
My MainWidget contains several buttons (with menus) and a subclass of
QGraphicsView, call it MainView.
I have some functionality associated with the mouse wheel, which has to
be performed fron the MainWidget class. It shall only be executed if the
mouse is over the Main View.
Therefore I implemeted:
class MainWidget : public QWidget{
//...
protected: void wheelEvent ( QWheelEvent * event )
{
if (m_view.underMouse())
{
//do the funcitonality
}
}
}
and the view ignores wheel events:
class MainView: public QGraphicsView{
//...
protected: void wheelEvent ( QWheelEvent * event )
{
event->ignore();
}
}
Thsi works perfectly, BUT:
As I said there are QPushButtons in my MainWidget with a menu.
If this menu is open, and if I click into the view in order to close the
menu, then the wheel funcitonality is not executed.
I was able to track this down, that the wheel event handler of the
MainView gets the event, but not the wheelevent handler of the MainWidget.
How can thsi be?
It is just if the menu of a button was open and if I click directly on
the view then.
If I click somehere else in my MainWidget, move the cursor over the view
and roll the wheel then,everything works fine.
Thanks in advance
Olli
More information about the Qt-interest-old
mailing list