其他分享
首页 > 其他分享> > Qt鼠标事件event

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

标签:鼠标,MYBUTTON,class,MyButton,include,enterEvent,event,Qt
来源: https://www.cnblogs.com/zhangxuechao/p/16548803.html