qt图形化界面开发DAY4

发布时间:2024年01月11日

#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
    this->setWindowIcon(QIcon(":/Logo/qq.jpg"));
    ui->lineEdit_username->setText("admin");
    ui->lineEdit_userpasswd->setText("123456");
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_close_clicked()
{
    this->close();
}

void Widget::on_pushButton_login_clicked()
{
    QString name=ui->lineEdit_username->text();
    QString passwd=ui->lineEdit_userpasswd->text();
    if(name == "admin" && passwd == "123456"){
        int ret = QMessageBox::information(this,
                                           "登录成功!",
                                           "将跳转下一个页面..",
                                           QMessageBox::Ok |QMessageBox::No);
        if(ret == QMessageBox::Ok){
            this->close();
            emit this->jump_alarm();
        }

    }else {
        int ret = QMessageBox::critical(this,
                                        "登录失败",
                                        "账号密码不匹配,是否重新登录",
                                        QMessageBox::Yes |QMessageBox::No);
        if(ret == QMessageBox::Yes){
            ui->lineEdit_username->clear();
            ui->lineEdit_userpasswd->clear();
        }else if(ret == QMessageBox::No){
            int ret = QMessageBox::question(this,
                                            "退出登录",
                                            "您是否确定要退出登录",
                                            QMessageBox::Yes |QMessageBox::No);
            if(ret == QMessageBox::Yes){
                this->close();
            }else if(ret == QMessageBox::No){
            }
        }
    }
}

文章来源:https://blog.csdn.net/xuesama/article/details/135537984
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。