6月15号作业

使用手动连接,将登录框中的取消按钮使用第二中连接方式,右击转到槽,在该槽函数中,调用关闭函数

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

widget.h

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QTextEdit>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
private slots:
    void on_canceBin_clicked();
    void my_slot();

    void on_pos2_clicked();

private:
    Ui::Widget *ui;
    QTextEdit *text1;
};
#endif // WIDGET_H

widget.cpp

#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
    ,text1(new QTextEdit)
{
    ui->setupUi(this);
    ui->bel1->setPixmap(QPixmap(":/pictrue/logo.png"));//标签贴图的路劲
    ui->bel1->setScaledContents(true);//自动适应调节
    ui->bel2->setPixmap(QPixmap(":/pictrue/wodepeizhenshi.png"));//标签贴图的路劲
    ui->bel2->setScaledContents(true);//自动适应调节
    ui->bel3->setPixmap(QPixmap(":/pictrue/passwd.jpg"));//标签贴图的路劲
    ui->bel3->setScaledContents(true);//自动适应调节
    ui->idt2->setEchoMode(QLineEdit::Password);//设置密码
    connect(ui->pos1,SIGNAL(clicked()),this,SLOT(my_slot()));
   // connect(text1,SIGNAL(),this,SLOT(my_slot()));
}

Widget::~Widget()
{
    delete ui;
}
void Widget::my_slot()
{
    if(ui->idt1->text()=="123456")
    {
        if(ui->idt2->text()=="123456")
        {
            text1->setText("登录成功");
            text1->resize(80,50);
            text1->show();
            this->close();
            return;
        }
    }
    text1->setText("登录失败");
    ui->idt2->setText("");
    text1->resize(80,50);
    text1->show();
}
void Widget::on_canceBin_clicked()
{
    this->close();
}


void Widget::on_pos2_clicked()
{
     this->close();
}

功能实现

思维导图

相关推荐

  1. 617

    2024-06-17 12:24:02       35 阅读
  2. 假期作业 26

    2024-06-17 12:24:02       45 阅读
  3. 寒假作业26

    2024-06-17 12:24:02       51 阅读
  4. 寒假作业213

    2024-06-17 12:24:02       50 阅读
  5. 28作业

    2024-06-17 12:24:02       47 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-17 12:24:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-17 12:24:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-06-17 12:24:02       82 阅读
  4. Python语言-面向对象

    2024-06-17 12:24:02       91 阅读

热门阅读

  1. 数组类模板(超详细)

    2024-06-17 12:24:02       27 阅读
  2. 使用Selenium进行元素定位的全面指南

    2024-06-17 12:24:02       21 阅读
  3. 安卓项目模块集成JNI的两种方式回顾

    2024-06-17 12:24:02       24 阅读
  4. 数据可视化:让数据讲述故事

    2024-06-17 12:24:02       32 阅读
  5. 使用 Verdaccio 建立私有npm库

    2024-06-17 12:24:02       31 阅读
  6. vue router中的导航守卫,它的5个使用场景举例

    2024-06-17 12:24:02       28 阅读
  7. SVG in VSCode: A Comprehensive Guide

    2024-06-17 12:24:02       32 阅读
  8. vscode 创建一个测试单个js文件的项目

    2024-06-17 12:24:02       33 阅读
  9. 网络命令大全windows linux

    2024-06-17 12:24:02       29 阅读