QT登录作业

发布于:2025-02-11 ⋅ 阅读:(57) ⋅ 点赞:(0)
#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
#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
#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();
}
#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();
}
#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("");
    }
}

 

*{
	
	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;
}

 

 

 


网站公告

今日签到

点亮在社区的每一天
去签到