#include "mlabel.h"
#include <QDebug>bgfb
#include <QEvent>
#include <QMouseEvent>
MLabel::MLabel(QWidget *parent) : QLabel(parent)
{
setMouseTracking(true); //设置鼠标自动跟随
}
void MLabel::enterEvent(QEvent */*ev*/)
{
qDebug() << "鼠标进入";
}
void MLabel::leaveEvent(QEvent */*ev*/)
{
qDebug() << "鼠标离开";
}
void MLabel::mousePressEvent(QMouseEvent *event)
{
QString str = QString("%1").arg(event->globalX());
qDebug() << "鼠标按下" << str;
}
void MLabel::mouseMoveEvent(QMouseEvent *event)
{
QString str = QString("%1 %2").arg(event->x()).arg(event->y());
qDebug() << "鼠标移动" << str;
}
qt鼠标自动跟随
最新推荐文章于 2022-11-14 15:10:50 发布