qss实现登录界面美化
#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);ui->lineEdit_2->setClearButtonEnabled(true);};Widget::~Widget()
{delete ui;
}void Widget::on_pushButton_clicked()
{QMessageBox box;//设置文本框的大小box.setStyleSheet("QLabel{""min-width: 200px;""min-height: 100px; ""font-size:10px;""text-align:center;""}");if(ui->lineEdit->text() == "admin") {if( ui->lineEdit_2->text() == "123456" ){//登录界面关闭跳转下一个界面emit my_jump_login();}else{box.setText("<font size='10' color='black'>账号或者密码错误</font>");box.setWindowTitle("登录失败");box.exec();}}else{box.setText("<font size='10' color='black'>账号或者密码错误</font>");box.setWindowTitle("登录失败");box.exec();}
}void Widget::on_pushButton_2_clicked()
{this->close();
}void Widget::on_pushButton_3_clicked()
{this->showMinimized();
}
登录
思维导图