- 文件名编辑为 style.qss
内容如:
QTextEdit{
background: #033441;
color:#64eefa;
border:1px solid #64eefa;
}
QLineEdit{
background: #033441;
color:#64eefa;
border:1px solid #64eefa;
}
QComboBox{
background: #033441;
color:#64eefa;
border:1px solid #64eefa;
}
QTreeWidget{
background: #033441;
color:#64eefa;
border:1px solid #64eefa;
}
QGroupBox{
color:#64eefa;
border:0.5px solid #64eefa;
}
QLineEdit#lineEdit_client_id,
QLineEdit#lineEdit_request_id,
QLineEdit#lineEdit_cjbh{
background: #535353;
color:#64eefa;
}
QLabel#label_jg,
QLabel#label_ret,
QLabel#label{
color:#64eefa;
}
QLabel#label_ret{
font-size:18px;
}
QDialog[objectName = "faceCheckDlg"]{
border-image: url(./imghx/check/body.png);
}
QWidget[objectName = "centralWidget"]{
border-image: url(./imghx/body.png);
}
QPushButton[objectName ="pushButton_cp"]{
border-image: url(./imghx/cp1.png);
}
QPushButton:disabled[objectName ="pushButton_cp"]{
border-image: url(./imghx/cp3.png);
}
QPushButton:pressed[objectName ="pushButton_cp"]{
border-image: url(./imghx/cp2.png);
}
- 在main.cpp加载文件
QFile file("./images/style.qss");
file.open(QFile::ReadOnly);
a.setStyleSheet(file.readAll());
file.close();
3.在代码中临时添加
ui.centralWidget->setStyleSheet("QWidget[objectName = 'centralWidget']{ border-image: url(./img/body.png); }");
ui.label_18->setStyleSheet("QLabel[objectName = 'label_18']{ border-image: url(./img/low.png); }");
ui.pushButton_reg->setStyleSheet("QPushButton[objectName = 'pushButton_reg']{ border-image: url(./img/reg2.png); }");
参考
Qt-QSS
https://blog.csdn.net/lmhuanying1012/category_7039268.html
QT之常用样式(样式代码可直接使用)
https://blog.csdn.net/panchang199266/article/details/104207844?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.channel_param
QSS样式表汇总
https://blog.csdn.net/LearnLHC/article/details/108669612?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-4.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-4.nonecase