首页 > 代码库 > QT_QLabel点击事件

QT_QLabel点击事件

 

    class login_window : public QWidget
    {
        Q_OBJECT

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

 

    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);
    }

 

QT_QLabel点击事件