Qt使用QSS
来源:互联网 发布:上海德比软件 编辑:程序博客网 时间:2024/05/20 23:39
1. 新建工程Qss,父类为MainWindow
2. 在工程目录下,新建文本文档style.txt,将后缀名改为.qss,即为style.qss
3. 新建资源文件qss.qrc,在该资源文件中添加新文件style.qss,
4.在style.qss中添加下列代码,改变程序中控件的样式
QMainWindow,QTabWidget,QTableWidget,QLineEdit,QComboBox,QTextEdit,QCheckBox,QSpinBox,QHeaderView,QScrollBar
{
background-color:rgba(134,183,200,255);
}
QPushButton
{
background-color:rgb(134,183,200);
border:2pxsolidrgb(0,255,255);
border-radius:5px;
color:white;
}
QLineEdit,QComboBox
{
background-color:rgb(134,183,200);
border:2pxsolid#5F92B2;
border-radius:3px;
}
QPushButton:hover
{
background-color:rgb(0,130,150);
border:2pxsolid#5F92B2;
border-radius:5px;
color:white;
}
QPushButton:hover:pressed
{
background-color:rgb(85,170,255);
border:2pxsolid#3C80B1;
border-radius:5px;
color:white;
}
5.在main.cpp中添加下列代码
#include "mainwindow.h"
#include <QApplication>
#include <QFile>
int main(int argc, char *argv[])
{
QApplicationa(argc, argv);
QString strQss;
QFileqssFile(":/style.qss");
qssFile.open(QFile::ReadOnly);
if(qssFile.isOpen())
{
strQss=QLatin1String(qssFile.readAll());
qApp->setStyleSheet(strQss);
qssFile.close();
}
MainWindow w;
w.show();
returna.exec();
}
使用后:
- QT QSS 使用
- QT QSS 使用
- Qt Qss使用
- Qt中使用Qss
- QT QSS 使用
- Qt使用QSS
- QT QSS 使用
- QT QSS 使用
- Qt使用qss
- Qt之QSS使用
- Qt qss使用总结
- Qt使用qss
- Qt使用QSS
- Qt之QSS使用
- QT中QSS的使用
- Qt中qss的使用
- QT布局以及使用QSS
- Qt qss
- 概率论笔记---组合分析(续)
- ProtocolBuffer的简单使用
- win7系统如何打开dos窗口
- 我爱江山或过无过过过过过过
- 算法系列——Contains Duplicate
- Qt使用QSS
- POJ-1087 二分图匹配,最大流。
- Web服务器使用JSP来创建网页的步骤
- vi命令
- 『数据结构』RMQ 问题
- 算法系列——Contains Duplicate II
- 算法系列——Contains Duplicate III
- linux之如何在任意目录执行我常用的脚本文件
- python学习笔记——控制流(if,while,for,break,continue,模拟登录小程序实例)