#ifndef MYLABEL_H #define MYLABEL_H #include <QObject> #include <QLabel> class MyLabel : public QLabel { Q_OBJECT public: explicit MyLabel(QObject *parent = nullptr); signals: void clicked(void); public slots: protected: virtual void mouseReleaseEvent(QMouseEvent * ev); }; #endif // MYLABEL_H
#include "mylabel.h" MyLabel::MyLabel(QObject *parent) : QLabel() { } void MyLabel::mouseReleaseEvent(QMouseEvent *ev) { Q_UNUSED(ev) emit clicked(); }