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){
            }
        }
    }
}
相关推荐
m0_51801948几秒前
C++中的装饰器模式变体
开发语言·c++·算法
SuperEugene4 分钟前
Vue3 + Element Plus 中后台弹窗规范:开闭、传参、回调,告别弹窗地狱|Vue 组件与模板规范篇
开发语言·前端·javascript·vue.js·前端框架
SuperEugene6 分钟前
VXE-Table 4.x 实战规范:列配置 + 合并单元格 + 虚拟滚动,避坑卡顿 / 错乱 / 合并失效|表单与表格规范篇
开发语言·前端·javascript·vue.js·前端框架·vxetable
xushichao19897 分钟前
高性能密码学库
开发语言·c++·算法
偷懒下载原神7 分钟前
【linux操作系统】信号
linux·运维·服务器·开发语言·c++·git·后端
小涛不学习8 分钟前
Java面试全攻略(基础 + 集合 + 并发 + JVM + 框架)
java·开发语言
m0_518019489 分钟前
C++代码混淆与保护
开发语言·c++·算法
m0_5698814712 分钟前
C++中的智能指针详解
开发语言·c++·算法
爱丽_19 分钟前
AQS 原理主线:state、CLH 队列、独占/共享与实战排查
java·开发语言·jvm
2401_8735449225 分钟前
基于C++的游戏引擎开发
开发语言·c++·算法