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;
}
相关推荐
Poetinthedusk12 小时前
设计模式-命令模式
windows·设计模式·c#·wpf·命令模式
刺客xs1 天前
Qt------信号槽,属性,对象树
开发语言·qt·命令模式
我有一棵树2 天前
基于 Vue3 动态组件的弹框流程管理:命令模式事件
命令模式
__万波__3 天前
二十三种设计模式(十四)--命令模式
java·设计模式·命令模式
⑩-5 天前
Java设计模式-命令模式
java·设计模式·命令模式
Yeniden5 天前
Deepeek用大白话讲解 --> 命令模式(企业级场景1,智能家居遥控器2,撤销重做3,宏命令4)
智能家居·命令模式
小灰灰搞电子5 天前
Qt 重写QRadioButton实现动态radioButton源码分享
开发语言·qt·命令模式
小灰灰搞电子7 天前
Qt 实现炫酷锁屏源码分享
开发语言·qt·命令模式
一只小bit7 天前
Qt Widget 控件介绍:覆盖常用属性及API
开发语言·c++·qt·命令模式·cpp
iFlow_AI8 天前
iFlow CLI 实战案例|生产级 Agent 聊天应用——Chatbot
交互·ai编程·命令模式·iflow·iflow cli·iflowcli