【发布时间】:2012-09-30 05:38:08
【问题描述】:
在 QT 中:我使用从 QToolButton 继承的类并重写 event(QEvent*),现在我想添加“mousePressEvent”,但它永远不会被击中,event(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:
};
【问题讨论】:
标签: qt button qevent mousepress