I have a QToolButton with a menu on it( InstantPopup ). I press the button, menu appears and after that I press outside the button, how should I catch this event related to my button?
I don't understand what event you want, but if you want catch an event of the QToolButton you can reimplement it virtual functions:
//For a mouse press and release event
virtual void mousePressEvent ( QMouseEvent * e )
virtual void mouseReleaseEvent ( QMouseEvent * e )
It's very easy.
At first that was my logic too but mouseReleaseEvent is not triggered for the above behaviour :)
Maybe you can reimplement virtual bool event ( QEvent * event ) and look what event is generate when you press outside the button.
@bool MyToolButton::event(QEvent event)
qDebug( (char)QString::number( event->type()).data() );
return QToolButton::event( event );
I don't get any event :( when I press outside my button( with the menu triggered )
When you say 'press outside the button' what you mean? What object is pressed?
I feel when you will click on ToolButton your InstantPopup will get in focus and when you will click out side it will go out of focus or deactivate. Try to catch event when deactivates.
Customized my QMenu and on hide event emited a signal to my button. Thanks for help ;)