在QT中:我使用从QToolButton继承的类并重写事件(QEvent *),现在我想添加'mousePressEvent',但它永远不会被击中,事件(QEvent *)是否与mousePressEvent(QMouseEvent *)冲突?谢谢你。
bool IconLabel::event (QEvent* e ) {
if ( e->type() == QEvent::Paint) {
return QToolButton::event(e);
}
return true;
}
void IconLabel::mousePressEvent(QMouseEvent* e)
{
int a = 1;//example
a = 2;// example//Handle the event
}
课程是:
class IconLabel : public QToolButton
{
Q_OBJECT
public:
explicit IconLabel(QWidget *parent = 0);
bool event (QEvent* e );
void mousePressEvent(QMouseEvent* e);
signals:
public slots:
};