I've overrode the eventFilter method of the MainWindow of the application
bool MainWindow::eventFilter(QObject *obj, QEvent *event){
if(event->type()== QEvent::MouseButtonRelease){
cout<<"CATCH"<<endl;
}
return QObject::eventFilter(obj,event);
}
I can get all events thrown by QWidgets except events arose by QPushButton and Widgets that implement the click event,I mean if I click on the background I can get the release event,if i click on a QLabel or a QWidget Container i still get the event, but I can't get mouse events from QPushButton, QCalendar, GroupBox etc...
I've tried to promote (I'm using QtCreator) the QPushButton overriding both the methods
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
But even this does not work because these methods are not called when clicking on the QPushButton. So I've overrode the filter method of the button and I can catch only graphic events like PaletteChangeEvent or RepaintingEvent.
What am I doing wrong?
QPushButton
has reimplemented eventFilter() for its own internal purposes and handles those events. Therefore they don't reach your event filter. - vahancho