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 小时前
命令模式
命令模式
lierenvip2 天前
SpringDoc和Swagger使用
命令模式
Anurmy12 天前
设计模式之命令模式
设计模式·命令模式
蜜獾云14 天前
设计模式之命令模式:给其他模块下达命令
设计模式·命令模式
江沉晚呤时15 天前
构建 .NET 9 Quartz 可视化调度系统(使用 Chet.QuartzNet.UI)
命令模式
夕珩16 天前
单例模式、原型模式、工厂方法模式、抽象工厂模式、建造者模式、解释器模式、命令模式
单例模式·解释器模式·建造者模式·工厂方法模式·抽象工厂模式·命令模式·原型模式
易水寒陈17 天前
单片机的命令模式
单片机·命令模式
vQFQJbUiJ1 个月前
matlab/simulink七自由度车辆模型 输入为路面不平度,输出车轮位置,车身位移,俯仰角
命令模式
geovindu1 个月前
python: Command Pattern
开发语言·python·命令模式
J_liaty1 个月前
23种设计模式一命令模式
设计模式·命令模式