I have the following widget's hierarchy:
root (QWidget)
|-> first child (QWidget)
|---> label A (QLabel)
|---> label B (QLabel)
|-> second child (QButton)
|-> third child (QButton)
what I am trying to achieve is to receive mouse release events on first child
(or both label A
and label B
, the behaviour would be the same anyway)
I tried using an event filter
MyWidget(QWidget* parent) : QWidget(parent) {
setupUi(this);
// some other stuff
mFirstChild->installEventFilter(this);
}
bool MyWidget::eventFilter(QObject* object, QEvent* event) {
if (event->type() == QEvent::MouseButtonRelease) {
// do stuff
return true;
}
return QWidget::eventFilter(object, event);
}
My problem is that my test doStuff()
method is never called. I correctly receive events like Enter, Leave, Repaint, MousePress, MouseDblClick, but I never get MouseRelease (nor MouseMove by the way).
Am I missing something obvious here ?
EDIT: After some more researches, I tried using WA_TransparentForMouseEvents
attribute, it did not change anything.