//在构造函数中 ui->btnGetRadarPara->setAttribute(Qt::WA_Hover, true); //开启悬停事件 ui->btnGetRadarPara->installEventFilter(this); //安装事件过滤器 ui->btnGetTargetInfo->setAttribute(Qt::WA_Hover, true); //开启悬停事件 ui->btnGetTargetInfo->installEventFilter(this); //安装事件过滤器 protected: bool eventFilter(QObject * obj, QEvent * event); bool RadarExternalPlatForm::eventFilter(QObject * obj, QEvent * event) { if(obj == ui->btnGetRadarPara) { if(event->type() == QEvent::HoverEnter) //当鼠标悬停在获取雷达参数按钮上 { m_pRadarLoader->SendGetCurRadarParamtersReqMsg(ui->editPlatFromID->text().toInt()); //获取雷达参数 return true; } } if(obj == ui->btnGetTargetInfo) { if(event->type() == QEvent::HoverEnter) //当鼠标悬停在获取雷达参数按钮上 { m_pRadarLoader->SendGetRadarDetectTargetInfo(ui->editPlatFromID->text().toInt()); //获取雷达参数 return true; } } return QDialog::eventFilter(obj, event); }