Qt鼠标事件event
#ifndef MYBUTTON_H
#define MYBUTTON_H
#include <QWidget>
#include <QDebug>
#include <QPushButton>
namespace Ui {
class MyButton;
}
class MyButton : public QPushButton
{
Q_OBJECT
public:
explicit MyButton(QWidget *parent = nullptr);
~MyButton();
void enterEvent(QEvent *event) override
{
qDebug() << "enterEvent";
}
void leaveEvent(QEvent *event) override
{
qDebug() << "leaveEvent";
}
private:
Ui::MyButton *ui;
};
#endif // MYBUTTON_H
/* 鼠标移动操作 进入离开 */
21:29:04: Starting ...
enterEvent
leaveEvent