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