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:
};