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();
    }
}
相关推荐
方安乐21 小时前
python之向量、向量和、向量点积
开发语言·python·numpy
小小小米粒1 天前
Collection单列集合、Map(Key - Value)双列集合,多继承实现。
java·开发语言·windows
智者知已应修善业1 天前
【51单片机中的打飞机设计】2023-8-25
c++·经验分享·笔记·算法·51单片机
czhc11400756631 天前
C# 428 线程、异步
开发语言·c#
:1211 天前
java基础
java·开发语言
SilentSamsara1 天前
Python 环境搭建完整指南:从下载安装到运行第一个程序
开发语言·python
小短腿的代码世界1 天前
Qt文件系统与IO深度解析:从QFile到异步文件操作
开发语言·qt
智者知已应修善业1 天前
【51单片机按键调节占空比3位数码管显示】2023-8-24
c++·经验分享·笔记·算法·51单片机
harder3211 天前
RMP模式的创新突破
开发语言·学习·ios·swift·策略模式
jinanwuhuaguo1 天前
OpenClaw工程解剖——RAG、向量织构与“记忆宫殿”的索引拓扑学(第十三篇)
android·开发语言·人工智能·kotlin·拓扑学·openclaw