【无标题】

本文详细描述了一个使用Qt库开发的窗口界面,包括背景颜色、文本样式、动画效果、无边框窗口、透明背景、自定义信号槽处理以及登录验证功能。
摘要由CSDN通过智能技术生成

qss:


QFrame#frame{
	background-color: rgba(167, 202, 207, 100);
}
QLabel#login{
	font: 20pt "等线";
	color: rgb(255, 255, 255);
}
#mainlab{
	background-color: rgb(0, 0, 0);
}
QLineEdit#userName{
	color: rgba(255, 255, 255, 100);
font: 17pt "等线";
background:transparent;/*完全透明*/
border:none;/*无边框*/
border-bottom:1px solid  rgba(255, 255, 255, 90);
}
#passwd{
	color: rgba(255, 255, 255, 100);
font: 17pt "等线";
background:transparent;/*完全透明*/
border:none;/*无边框*/
border-bottom:1px solid  rgba(255, 255, 255, 90);
}
#find{
font: 10pt "楷体";
background:transparent;/*完全透明*/
border:none;/*无边框*/
}
#edit{
	font: 11pt "楷体";
background:transparent;/*完全透明*/
border:none;/*无边框*/
}
QPushButton#Login{
border-radius:10px;
	color: rgb(0, 0, 0);
font: 14pt "等线";
	background-color: qlineargradient(spread:pad, x1:0.515833, y1:0, x2:0.505208, y2:1, stop:0 rgba(0, 170, 255, 255), stop:0.260417 rgba(72, 216, 216, 255), stop:0.98 rgba(85, 255, 255, 255), stop:1 rgba(0, 0, 0, 0));
}
QPushButton#Login:hover{    /*鼠标移动*/
border-radius:10px;
	color: rgb(0, 0, 0);
font: 14pt "等线";
	background-color: qlineargradient(spread:pad, x1:0.515833, y1:0, x2:0.505208, y2:1, stop:0 rgba(30, 170, 255, 255), stop:0.260417 rgba(72, 216, 216, 255), stop:0.98 rgba(85, 255, 255, 255), stop:1 rgba(0, 0, 0, 0));
}
QPushButton#Login:pressed{   /*鼠标按下*/
border-radius:10px;
	color: rgb(0, 0, 0);
font: 14pt "等线";
	background-color: qlineargradient(spread:pad, x1:0.515833, y1:0, x2:0.505208, y2:1, stop:0 rgba(0, 170, 255, 255), stop:0.260417 rgba(72, 216, 216, 255), stop:0.98 rgba(85, 255, 255, 255), stop:1 rgba(0, 0, 0, 0));
 
padding-top:5px;
padding-left:5px;
}
#quit{
	font: 28pt "等线";
background:transparent;/*完全透明*/
	color: rgb(255, 255, 255);
}
#quit:hover{
	color: rgb(255, 255, 255);
	background-color: rgb(170, 0, 0);
}
#Mini{
	font: 28pt "等线";
background:transparent;/*完全透明*/
	color: rgb(255, 255, 255);
}
#Mini:hover{
	color: rgb(255, 255, 255);
	background-color: rgb(170, 0, 0);
}
QCheckBox#checkBox{
	font: 10pt "楷体";
}
#checkBox_2{
font: 10pt "楷体";
}

源文件:

#include "widget.h"
#include "ui_widget.h"
 
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
 
    //动图动起来
    QMovie *mv = new QMovie(":/Logo/preview.gif");
    ui->mainlab->setMovie(mv);
    mv->start();
    ui->mainlab->setScaledContents(true);
 
    //纯净窗口
    this->setWindowFlag(Qt::FramelessWindowHint);
 
    //去掉空白
    this->setAttribute(Qt::WA_TranslucentBackground);
 
    //手动连接自定义信号和槽函数,实现窗口关闭
    connect(ui->quit, SIGNAL(clicked()), this, SLOT(clicked_close()));
 
    //手动连接自定义信号和槽函数,实现窗口关闭
    connect(ui->Mini, SIGNAL(clicked()), this, SLOT(clicked_Mini()));
 
    //使用qt5版本,手动连接信号和自定义槽函数
    connect(ui->Login, &QPushButton::clicked, this, &Widget::clicked_Login);
 
}
 
Widget::~Widget()
{
    delete ui;
}
 
//退出窗口
void Widget::clicked_close()
{
    this->close();
}
//最小化界面
void Widget::clicked_Mini()
{
    this->setWindowState(Qt::WindowMinimized);
}
 
void Widget::clicked_Login()
{
    if(ui->userName->text() == "admin" && ui->passwd->text() == "123456")
    {
 
        ui->edit->setText("登录成功");
    }
    else
    {
        ui->edit->setStyleSheet("color:red");
        ui->edit->setText("登录失败,请重新输入");
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值