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();
    }
}
相关推荐
Python×CATIA工业智造1 小时前
Frida RPC高级应用:动态模拟执行Android so文件实战指南
开发语言·python·pycharm
十五年专注C++开发2 小时前
CMake基础:条件判断详解
c++·跨平台·cmake·自动化编译
我叫小白菜2 小时前
【Java_EE】单例模式、阻塞队列、线程池、定时器
java·开发语言
狐凄2 小时前
Python实例题:基于 Python 的简单聊天机器人
开发语言·python
weixin_446122463 小时前
JAVA内存区域划分
java·开发语言·redis
悦悦子a啊3 小时前
Python之--基本知识
开发语言·前端·python
QuantumStack4 小时前
【C++ 真题】P1104 生日
开发语言·c++·算法
天若有情6734 小时前
01_软件卓越之道:功能性与需求满足
c++·软件工程·软件
whoarethenext4 小时前
使用 C++/OpenCV 和 MFCC 构建双重认证智能门禁系统
开发语言·c++·opencv·mfcc
代码的奴隶(艾伦·耶格尔)5 小时前
后端快捷代码
java·开发语言