*{
background-color: rgb(255, 255, 255);
}
QFrame#frame{
border-radius:25px;
border-image: url(:/Logo/shanChuan.jpg);
}
#frame_2{
border-radius:25px;
background-color: rgba(154, 154, 154, 120);
}
QLabel#label{
border-radius:25px;
background-color: rgba(103, 103, 103, 120);
}
#label_2{
background:transparent;
color: white;
font: 75 15pt "Times New Roman";
color: rgba(255, 255, 255, 140);
}
QLineEdit{
background:transparent;
border:none;
border-bottom:1px solid rgba(255, 255, 255, 120);
color: rgba(255, 255, 255, 120);
font: 9pt "Times New Roman";
}
QPushButton#pushButton{
color: rgba(255, 255, 255, 120);
font: 14pt "Times New Roman";
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(46, 122, 214, 255), stop:1 rgba(255, 255, 255, 255));
border-radius:5px;
}
QPushButton:hover#pushButton{
color: rgba(255, 255, 255, 120);
font: 14pt "Times New Roman";
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(80, 122, 214, 255), stop:1 rgba(255, 255, 255, 255));
border-radius:5px;
}
QPushButton:pressed#pushButton{
color: rgba(255, 255, 255, 120);
font: 14pt "Times New Roman";
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(46, 122, 214, 255), stop:1 rgba(255, 255, 255, 255));
border-radius:5px;
padding-top:5px;
padding-left:5px;
}
QPushButton#closeButton{
background-color: transparent;
border: none;
font: 75 16pt "等线";
border-radius:5px;
}
QPushButton:hover#closeButton{
background-color: transparent;
border: none;
font: 75 16pt "等线";
background-color: rgba(255, 0, 0, 80);
border-radius:5px;
}
QPushButton:pressed#closeButton{
background-color: transparent;
border: none;
font: 75 16pt "等线";
border-radius:5px;
padding-top:5px;
padding-left:5px;
}
QPushButton#shrinkButton{
background-color: transparent;
border: none;
border-radius:5px;
font: 75 30pt "等线";
}
QPushButton:hover#shrinkButton{
background-color: transparent;
border: none;
border-radius:5px;
background-color: rgba(255, 238, 244, 80);
font: 75 30pt "等线";
}
QPushButton:pressed#shrinkButton{
background-color: transparent;
border: none;
font: 75 30pt "等线";
border-radius:5px;
padding-top:5px;
padding-left:5px;
}
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QMessageBox>
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
private slots:
void on_pushButton_clicked();
void on_closeButton_clicked();
void on_shrinkButton_clicked();
signals:
void jumpToSecondWindow();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
setWindowFlag(Qt::FramelessWindowHint);
// 去掉空白
setAttribute(Qt::WA_TranslucentBackground);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_clicked()
{
if(ui->actLineEdit->text() == "admin" && ui->pwdLineEdit->text() == "123456")
{
close();
emit jumpToSecondWindow();
}
else
{
QMessageBox::critical(this, "Login Error", "账号或密码错误!");
// 清空账号和密码输入行
ui->actLineEdit->clear();
ui->pwdLineEdit->clear();
}
}
void Widget::on_closeButton_clicked()
{
close();
}
void Widget::on_shrinkButton_clicked()
{
showMinimized();
}
Second.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 mySlot();
private:
Ui::Second *ui;
};
#endif // SECOND_H
Second.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::mySlot()
{
show();
}