bool MyLabel::event(QEvent *event) { // 一般不会用来做事件拦截,通常用来做事件分发 if(event->type() == QEvent::MouseButtonPress){ QMouseEvent *ev=static_cast<QMouseEvent *>(event); QString str= QString("Event:::鼠标摁下x = %1,y = %2").arg(ev->x()).arg(ev->y()); qDebug()<<"我捕获到"<<str; return true; } return QLabel::event(event); }