QT_QLabel點擊事件


 

    class login_window : public QWidget
    {
        Q_OBJECT

    protected:
        bool eventFilter(QObject * watched, QEvent * event);
    }

 

        ui.label_obj_sample->installEventFilter(this);
        ui.label_zip_sample->installEventFilter(this);

 

    bool login_window::eventFilter(QObject * watched, QEvent * event)
    {
        
        if (watched == ui.label_forget_key &&
            event->type() == QEvent::MouseButtonPress)
        {
            QMessageBox::information(NULL, "Title", QStringLiteral("忘記密碼"), QMessageBox::Cancel );
        }
        else  if (watched == ui.label_apply &&
            event->type() == QEvent::MouseButtonPress)
        {
            QMessageBox::information(NULL, "Title", QStringLiteral("申請權限"), QMessageBox::Cancel );
        }
        return QWidget::eventFilter(watched, event);
    }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM