qt图形化界面开发DAY4

cpp 复制代码
#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){
            }
        }
    }
}
相关推荐
bst@微胖子21 分钟前
Python高级语法之selenium
开发语言·python·selenium
王小义笔记26 分钟前
Postman如何流畅使用DeepSeek
开发语言·测试工具·lua·postman·deepseek
java1234_小锋2 小时前
一周学会Flask3 Python Web开发-request请求对象与url传参
开发语言·python·flask·flask3
流星白龙5 小时前
【C++】36.C++IO流
开发语言·c++
诚信爱国敬业友善6 小时前
常见排序方法的总结归类
开发语言·python·算法
nbsaas-boot7 小时前
Go 自动升级依赖版本
开发语言·后端·golang
架构默片7 小时前
【JAVA工程师从0开始学AI】,第五步:Python类的“七十二变“——当Java的铠甲遇见Python的液态金属
java·开发语言·python
不只会拍照的程序猿8 小时前
从插入排序到希尔排序
java·开发语言·数据结构·算法·排序算法
小哥山水之间8 小时前
在 Python 中操作 Excel 文件
开发语言·python·excel
就爱学编程8 小时前
C语言预编译
c语言·开发语言