views:

37

answers:

1

How can I detect whether a double click on a QWidget (QStatusBar, in my case) occured while a modifier key was held down?

I can overload void QWidget::mouseDoubleClickEvent ( QMouseEvent * event ) to get the double click, but how can I sure whether the widget receives the key events when it might not have the focus?

+1  A: 

I found the answer:

QMouseEvent is derived from QInputEvent and that has a method called modifiers():

From the Qt documentation:

Returns the keyboard modifier flags that existed immediately before the event occurred.

Fabian Wickborn
did you actually test this approach, Qt Doc states aswell that these are not 100% trustable.
penguinpower
Yes, I have an event filter installed on a `QWidget` which casts the event into `QMouseEvent *` and tests two modifier keys in case the event is of type `QEvent::MouseButtonDblClick. Works like a charm...
Fabian Wickborn