C++DAY47

头文件

cpp 复制代码
#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QDebug>


QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
signals:
    void my_signal();
public slots:
    void my_slot();
    void my_on();

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

源文件

cpp 复制代码
#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setWindowTitle("300英雄");
    this->setWindowIcon(QIcon(":/pic/d.gif"));
    this->setWindowFlag(Qt::FramelessWindowHint);

    ui->labe1->setPixmap(QPixmap(":/pic/5.jpg"));
    ui->labe1->setScaledContents(true);
    ui->labe2->setPixmap(QPixmap(":/pic/6.jpg"));
    ui->labe2->setScaledContents(true);
    ui->labe3->setPixmap(QPixmap(":/pic/3.gif"));
    ui->labe3->setScaledContents(true);

    ui->username->setPlaceholderText("账号");
    ui->password->setPlaceholderText("密码");
    ui->password->setEchoMode(QLineEdit::Password);

    this->connect(ui->Btn2,SIGNAL(clicked()),this,SLOT(my_slot()));

    connect(ui->Btn1,&QPushButton::clicked,this,&Widget::my_on);
}

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



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

void Widget::my_on()
{
    if(ui->username->text() == "admin")
    {
        if(ui->password->text() == "123456")
        {
            qDebug() << "登录成功";
            this->close();
        }
        else
        {
            qDebug() << "登录失败";
            ui->password->clear();
        }
    }
    else
    {
        qDebug() << "登录失败";
        ui->username->clear();
        ui->password->clear();
    }
}
相关推荐
kesteler1 分钟前
R-切割数据
开发语言·r语言
哞哞不熬夜8 分钟前
JavaEE--SpringIoC
java·开发语言·spring boot·spring·java-ee·maven
newxtc12 分钟前
【猿辅导-注册安全分析报告-无验证方式导致安全隐患】
开发语言·selenium·安全·yolo·安全爆破
张人玉14 分钟前
c#WPF基础知识
开发语言·c#·wpf
AA陈超22 分钟前
虚幻引擎5 GAS开发俯视角RPG游戏 P06-09 玩家等级与战斗接口
c++·游戏·ue5·游戏引擎·虚幻
·白小白37 分钟前
力扣(LeetCode) ——118.杨辉三角(C++)
c++·算法·leetcode
tongsound41 分钟前
libmodbus 使用示例
linux·c++
std78791 小时前
Rust 与 Go – 比较以及每个如何满足您的需求
开发语言·golang·rust
报错小能手1 小时前
python(入门)map内置函数及import模块导入,as别名
开发语言·人工智能·python
梵得儿SHI1 小时前
Java 反射机制实战:对象属性复制与私有方法调用全解析
java·开发语言·java反射机制的实际应用·对象属性复制·反射调用私有方法·私有字段·类型兼容性和敏感字段忽略