【QT】day3

1.登陆界面【QT】day3_第1张图片
2.登陆失败【QT】day3_第2张图片
3.登陆成功弹窗
【QT】day3_第3张图片
4.点击OK后跳转
【QT】day3_第4张图片

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

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

void MainWindow::on_pushButton_clicked()
{
    QString username = ui->lineEdit->text();
    QString password = ui->lineEdit_2->text();
    if(username=="1" && password=="1")
    {
        int ret = QMessageBox::question(this,"问题","登陆成功",QMessageBox::Ok);
        if(ret == QMessageBox::Ok)
        {
            emit this->tohome();
            this->close();
        }
    }else{
        int ret = QMessageBox::question(this,"问题","登陆失败",QMessageBox::Yes | QMessageBox::No);
        if(ret == QMessageBox::Ok)
        {
            this->close();
        }else if(ret == QMessageBox::No)
        {
            ui->lineEdit->setText("");
            ui->lineEdit_2->setText("");
        }
    }
}

【QT】day3_第5张图片

你可能感兴趣的:(qt,命令模式,开发语言)