标签:his ttext nbsp type family class eve 过滤器 bsp
1.每一个控件都有
bool event(QEvent *event);
bool eventFilter(QObject *watched, QEvent *event); //事件过滤器,就是什么控件想捕获怎样的事件
ui->label->installEventFilter(this); //label控件安装过滤器 ui->label->setMouseTracking(true); //设置鼠标跟踪 bool Widget::eventFilter(QObject *watched, QEvent *event) { if(watched == ui->label) { static int t = 0; QMouseEvent *env = (QMouseEvent *)(event); //鼠标事件 if(event->type() == QEvent::MouseMove) //移动事件 { ui->label->setText(QString("%1").arg(t++)); return true; } } return QWidget::eventFilter(watched,event); }
标签:his ttext nbsp type family class eve 过滤器 bsp
原文地址:https://www.cnblogs.com/mathyk/p/9902189.html