All QObjects have an event() method that receives events. For QWidgets, this method will relay the event object to more specific event handlers. It is possible to redefine what an event handler should do by sub-classing the widget of interest and re-implementing that event handler.
Let's create an application where we shall re-implement an event handler.
Create a folder containing the main.cpp, mainwindow.cpp, and mainwindow.h files. The mainwindow.h file should contain the following code:
#include <QMainWindow>
#include <QMoveEvent>
#include <QMainWindow>
class MainWindow: public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
protected:
void moveEvent(QMoveEvent *event);
};
In the preceding code, we have only sub-classed QMainWindow. A default constructor is declared and the event handler that we want to override...