Qt的鼠标悬停事件


//在构造函数中
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);
    }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM