QT登录作业

cpp 复制代码
#ifndef WIDGET_H
#define WIDGET_H
 
#include <QWidget>
#include <QDebug>
#include <QMessageBox>
 
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_jump();
 
private slots:
    void on_pushButton_clicked();
 
private:
    Ui::Widget *ui;
};
#endif // WIDGET_H
cpp 复制代码
#ifndef SECOND_H
#define SECOND_H
 
#include <QWidget>
 
namespace Ui {
class Second;
}
 
class Second : public QWidget
{
    Q_OBJECT
 
public:
    explicit Second(QWidget *parent = nullptr);
    ~Second();
 
public slots:
    void jump_slot();
 
private:
    Ui::Second *ui;
};
 
#endif // SECOND_H
cpp 复制代码
#include "widget.h"
#include"second.h"
 
 
#include <QApplication>
 
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();
 
 
    Second s;
    QObject::connect(&w, &Widget::my_jump,&s,&Second::jump_slot);
    return a.exec();
}
cpp 复制代码
#include "second.h"
#include "ui_second.h"
 
Second::Second(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Second)
{
    ui->setupUi(this);
}
 
Second::~Second()
{
    delete ui;
}
 
void Second::jump_slot()
{
    this->show();
}
cpp 复制代码
#include "widget.h"
#include "ui_widget.h"
 
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
}
 
Widget::~Widget()
{
    delete ui;
}
 
 
void Widget::on_pushButton_clicked()
{
    if(ui->lineEdit->text() == "admin" && ui->lineEdit_2->text() == "123456")
    {
        qDebug() << "登录成功!";
        this->close();
        emit my_jump();
    }
    else
    {
        qDebug() << "登录失败!";
        QMessageBox::critical(this, "错误", "用户名或密码错误!");
        ui->lineEdit_2->setText("");
    }
}
cpp 复制代码
*{
	
	background-color: rgb(255, 255, 255);
}
 
QFrame#frame{
	
	border-image: url(:/Logo/shanChuan.jpg);
	border-radius:30px;
}
#frame_2{
	
	border-radius:30px;
	background-color: rgba(173, 173, 173, 120);
}
 
QLabel#label{
	
	background-color: rgb(88, 88, 88, 120);
	border-radius:30px;
}
#label_2{
	
	font: 18pt "等线";
	background:transparent;
 
	
	color: rgba(255, 255, 255, 150);
}
 
QLineEdit{
	background:transparent;
	border:none;
	border-bottom:1px solid rgba(255, 255, 255, 150);
	
	color: rgba(255, 255, 255, 150);
}
 
QPushButton{
	
	font: 10pt "等线";
	
	color: rgba(255, 255, 255, 150);
	
	background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(75, 109, 247, 255), stop:1 rgba(255, 255, 255, 255));
	border-radius:8px;
}
 
QPushButton:hover{/*鼠标移动*/
	
	font: 10pt "等线";
	
	color: rgba(255, 255, 255, 150);
	
	background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(115, 109, 247, 255), stop:1 rgba(255, 255, 255, 255));
	border-radius:8px;
}
 
QPushButton:pressed{/*鼠标按下*/
	
	font: 10pt "等线";
	
	color: rgba(255, 255, 255, 150);
	
	background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(75, 109, 247, 255), stop:1 rgba(255, 255, 255, 255));
	border-radius:8px;
	padding-top:5px;
	padding-left:5px;
}
相关推荐
ximu_polaris1 天前
设计模式(C++)-行为型模式-命令模式
c++·设计模式·命令模式
其实防守也摸鱼7 天前
GDB安装与配置(保姆级教程)【Linux、Windows系统】
linux·运维·windows·命令模式·工具·虚拟机·调试
其实防守也摸鱼12 天前
无线网络安全---WLAN相关安全工具--kali(理论附题目)
linux·安全·web安全·学习笔记·kali·命令模式·wlan
sg_knight14 天前
设计模式实战:命令模式(Command)
python·设计模式·命令模式
yaaakaaang14 天前
十四、命令模式
java·命令模式
无籽西瓜a14 天前
【西瓜带你学设计模式 | 第十八期 - 命令模式】命令模式 —— 请求封装与撤销实现、优缺点与适用场景
java·后端·设计模式·软件工程·命令模式
23.23 天前
【Linux】grep -F 及 双横线--的妙用
linux·命令模式
摸鱼仙人~25 天前
快照模式 vs 命令模式:一篇分清什么时候用谁
命令模式
2301_7644413325 天前
Dify工作流中实现查询优化(QO):将查询复杂度分类法与QOL框架融入工作流
人工智能·语言模型·自然语言处理·命令模式
fe7tQnVan25 天前
三大 Agent-UI 协议深度剖析:AG-UI、A2UI 与 MCP-UI 的设计哲学与工程实践
ui·状态模式·命令模式