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;
}
相关推荐
23.3 天前
【Linux】grep -F 及 双横线--的妙用
linux·命令模式
摸鱼仙人~5 天前
快照模式 vs 命令模式:一篇分清什么时候用谁
命令模式
2301_764441335 天前
Dify工作流中实现查询优化(QO):将查询复杂度分类法与QOL框架融入工作流
人工智能·语言模型·自然语言处理·命令模式
fe7tQnVan5 天前
三大 Agent-UI 协议深度剖析:AG-UI、A2UI 与 MCP-UI 的设计哲学与工程实践
ui·状态模式·命令模式
程序员小寒7 天前
JavaScript设计模式(八):命令模式实现与应用
前端·javascript·设计模式·ecmascript·命令模式
砍光二叉树10 天前
【设计模式】行为型-命令模式
设计模式·命令模式
心前阳光13 天前
UI在指定区域内拖拽
ui·命令模式
青春易逝丶13 天前
命令模式
命令模式
lierenvip15 天前
SpringDoc和Swagger使用
命令模式
Anurmy25 天前
设计模式之命令模式
设计模式·命令模式