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?
You have to install an EventFilter in your buttons and QWidgets to receive the events that are sent to those objects before them.
By doing that you can define a method that receive all the events that are sent to those objects and you can catch the ones you want.
Read this to see an example: Event Filters