I have a QLabel within my Qt Designer-created MainWindow.

However, I would like to add mouse tracking to this QLabel by subclassing QLabel and creating a new class called QLabelWithMouseTracking which will contains re-implementations of the appropriate protected functions: mousePressEvent(), mouseReleaseEvent() etc.

My question is:

How do I perform the subclassing and create a new class given that this QLabel is already created and initialized in the Designer UI header file?

Also, I'm using the multi-inheritance approach. i.e.

Qt Code:
  1. #include "ui_MainWindow.h"
  2.  
  3. class MainWindow : public QMainWindow, private Ui::MainWindow
  4. {
  5. Q_OBJECT
  6.  
  7. public:
  8. MainWindow(QWidget *parent = 0);
  9. };
To copy to clipboard, switch view to plain text mode 

etc.

Thanks in advance to anyone who can steer me in the right direction!