QT3作业

1

使用手动连接,将登录框中的取消按钮使用qt4版本的连接到自定义的槽函数中,在自定义的槽函数中调用关闭函数,将登录按钮使用t5版本的连接到自定义的槽函数中,在槽函数中判断ui界面上输入的账号是否为"admin",密码是否为"23456"。如果账号密码匹配成功,则输出"登录成功",并关闭该界面,如果匹配失败,则输出登录失败,并将密码框中的内容清空

#include "mywindow.h"
#include "ui_mywindow.h"

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

    //动图
    QMovie *mv=new QMovie("C:\\Users\\18065\\Desktop\\pictrue\\kun.gif");
    //设置父类
    mv->setParent(this);
    ui->Lable1->setMovie(mv);
    mv->start();
    ui->Lable1->setScaledContents(true);

    ui->Label2->setPixmap(QPixmap("C:\\Users\\18065\\Desktop\\pictrue\\tou.jpg"));
    ui->Label3->setPixmap(QPixmap("C:\\Users\\18065\\Desktop\\pictrue\\tou.jpg"));

    connect(ui->Bton2,SIGNAL(clicked()),this,SLOT(my_function()));
    connect(ui->Bton,&QPushButton::clicked,this,&myWindow::my_function2);
}

void myWindow::my_function()
{
    emit close();
}
void myWindow::my_function2()
{
    if((ui->lineEdit1->text() =="admin") && (ui->lineEdit2->text() == "123456"))
    {
        qDebug() << "登陆成功";
        emit close();
    }
    else
    {
        qDebug() << "登录失败";
        ui->lineEdit2->setText("");
    }
}
相关推荐
三玖诶2 天前
在 Qt 中使用 QLabel 设置 GIF 动态背景
开发语言·qt·命令模式
我码玄黄3 天前
JS 的行为设计模式:策略、观察者与命令模式
javascript·设计模式·命令模式
jzpfbpx3 天前
[go] 命令模式
开发语言·golang·命令模式
图像处理大大大大大牛啊7 天前
使用mingw64 编译 QT开发流程
开发语言·c++·qt·命令模式
写bug如流水7 天前
【FastAPI】离线使用Swagger UI 或 国内网络如何快速加载Swagger UI
ui·fastapi·命令模式
AI让世界更懂你8 天前
漫谈设计模式 [13]:命令模式
python·设计模式·命令模式
2401_839115739 天前
9.11.
命令模式
纵码驰骋9 天前
探索最佳 Shell 工具:全面测评 Bash、Zsh、Fish、Tcsh 和 Ksh
linux·服务器·ide·ssh·bash·策略模式·命令模式
榴月子11 天前
命令模式(Command Pattern)
java·命令模式
胖虎江11 天前
9.9(QT Day 2)
开发语言·qt·命令模式