马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- #ifndef FAILURE_H
- #define FAILURE_H
- #include <QWidget>
- #include <QTimer>
- namespace Ui {
- class failure;
- }
- class failure : public QWidget
- {
- Q_OBJECT
- public:
- explicit failure(QWidget *parent = nullptr);
- ~failure();
- public slots:
- void failure_slot();
- private:
- Ui::failure *ui;
- };
- #endif // FAILURE_H
复制代码- #ifndef SUCCESS_H
- #define SUCCESS_H
- #include <QWidget>
- namespace Ui {
- class Success;
- }
- class Success : public QWidget
- {
- Q_OBJECT
- public:
- explicit Success(QWidget *parent = nullptr);
- ~Success();
- signals:
- void my_return();
- public slots:
- void Login_success();
- private slots:
- void on_pushButton_clicked();
- private:
- Ui::Success *ui;
- };
- #endif // SUCCESS_H
复制代码- #ifndef WIDGET_H
- #define WIDGET_H
- #include <QWidget>
- #include <QTimer>
- 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_login();
- void my_failure();
- public slots:
- void return_slot();
- private slots:
- void on_pushButton_clicked();
- void on_pushButton_2_clicked();
- private:
- Ui::Widget *ui;
- };
- #endif // WIDGET_H
复制代码- #include "failure.h"
- #include "ui_failure.h"
- failure::failure(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::failure)
- {
- ui->setupUi(this);
- //去掉头部
- this->setWindowFlag(Qt::FramelessWindowHint);
- //去掉组件空白部分
- this->setAttribute(Qt::WA_TranslucentBackground);
- }
- failure::~failure()
- {
- delete ui;
- }
- void failure::failure_slot()
- {
- this->show();
- QTimer::singleShot(600,this,[this]()
- {
- this->close();
- });
- }
复制代码- #include "widget.h"
- #include <QApplication>
- #include "success.h"
- #include "failure.h"
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- Widget w;
- w.show();
- Success s;
- failure f;
- QObject::connect(&w,&Widget::my_login,&s,&Success::Login_success);
- QObject::connect(&s,&Success::my_return,&w,&Widget::return_slot);
- QObject::connect(&w,&Widget::my_failure,&f,&failure::failure_slot);
- return a.exec();
- }
复制代码- #include "success.h"
- #include "ui_success.h"
- Success::Success(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::Success)
- {
- ui->setupUi(this);
- //去掉头部
- this->setWindowFlag(Qt::FramelessWindowHint);
- }
- Success::~Success()
- {
- delete ui;
- }
- void Success::Login_success()
- {
- this->show();
- }
- void Success::on_pushButton_clicked()
- {
- emit my_return();
- this->close();
- }
复制代码- #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::return_slot()
- {
- this->show();
- }
- void Widget::on_pushButton_clicked()
- {
- if(ui->lineEdit->text()=="admin"&&ui->lineEdit_2->text()=="123456")
- {
- emit my_login();
- this->close();
- }
- else
- {
- ui->lineEdit_2->setText("");
- emit my_failure();
- }
- }
- void Widget::on_pushButton_2_clicked()
- {
- ui->lineEdit->setText("");
- ui->lineEdit_2->setText("");
- }
复制代码- *{
- background-color: rgb(255, 255, 255);
- border-radius:30px;
- }
- QFrame#frame{
-
- background-color: qconicalgradient(cx:0.5, cy:0.5, angle:0, stop:0 rgba(0, 255, 255, 255), stop:0.373979 rgba(255, 255, 255, 255), stop:0.373991 rgba(33, 30, 255, 255), stop:0.624018 rgba(33, 30, 255, 255), stop:0.624043 rgba(255, 0, 0, 255), stop:1 rgba(255, 0, 0, 255));
- border-image: url(:/Logo/shangHai.jpg);
- border-radius:30px;
-
- }
- #frame_2{
-
- background-color: rgba(130, 130, 130, 100);
- border-radius:30px;
- }
- QLabel#label{
- background-color: rgba(154, 154, 154, 100);
- border-radius:30px;
- }
- QLabel#label_2{
- font: 20pt "楷体";
- border-radius:30px;
- background-color: rgba(255, 255, 255, 0);
- color: rgba(255, 255, 255, 150);
- }
- QLineEdit#lineEdit
- {
- background:transparent;
- border:none;
- border-bottom:1px solid rgba(255,255,255,150);
- color: rgba(255, 255, 255, 150);
- }
- QLineEdit#lineEdit_2
- {
- background:transparent;
- border:none;
- border-bottom:1px solid rgba(255,255,255,150);
- color: rgba(255, 255, 255, 150);
- }
- QLineEdit#lineEdit_3
- {
- background:transparent;
- border:none;
- border-bottom:1px solid rgba(255,255,255,150);
- }
- QPushButton#pushButton
- {
- border-radius:10px;
- color: rgba(255, 255, 255, 150);
-
- background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 145, 171, 255), stop:1 rgba(255, 255, 255, 255));
- }
- QPushButton#pushButton:hover
- {
- border-radius:10px;
- color: rgba(255, 255, 255, 150);
-
- background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 185, 171, 255), stop:1 rgba(255, 255, 255, 255));
- }
- QPushButton#pushButton:pressed
- {
- border-radius:10px;
- color: rgba(255, 255, 255, 150);
-
- background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 145, 171, 255), stop:1 rgba(255, 255, 255, 255));
- padding-top:5px;
- }
- QPushButton#pushButton_2
- {
- border-radius:10px;
- color: rgba(255, 255, 255, 150);
-
- background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 145, 171, 255), stop:1 rgba(255, 255, 255, 255));
- }
- QPushButton#pushButton_2:hover
- {
- border-radius:10px;
- color: rgba(255, 255, 255, 150);
-
- background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 185, 171, 255), stop:1 rgba(255, 255, 255, 255));
- }
- QPushButton#pushButton_2:pressed
- {
- border-radius:10px;
- color: rgba(255, 255, 255, 150);
-
- background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 145, 171, 255), stop:1 rgba(255, 255, 255, 255));
- padding-top:5px;
- }
- QPushButton#pushButton_3
- {
- border-radius:10px;
- color: rgba(255, 255, 255, 150);
-
- background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 145, 171, 255), stop:1 rgba(255, 255, 255, 255));
- }
- QPushButton#pushButton_3:hover
- {
- border-radius:10px;
- color: rgba(255, 255, 255, 150);
-
- background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 185, 171, 255), stop:1 rgba(255, 255, 255, 255));
-
- }
复制代码
输入账号暗码,账号暗码正确,登录乐成

关掉本界面,弹出下一个界面,点击返回回到刚才的界面

如果账号暗码错误,则弹出登录失败,6秒后消散

|