标签:readonly only update turn open ado ati def col
1.不同的皮肤配置写在不同的.qss文件。
2.在main加载默认的皮肤文件
#include "mainwindow.h" #include <QApplication> #include <QFile> int main(int argc, char *argv[]) { QApplication a(argc, argv); QFile qss_file(":/default.qss"); if(!qss_file.open(QFile::ReadOnly)) { //qDebug()<<"qss file open error"; } qApp->setStyleSheet(qss_file.readAll()); qss_file.close(); MainWindow w; w.show(); return a.exec(); }
3.更换皮肤,重新加载指定的皮肤文件qss。
void MainWindow::updateTheme() { QFile qss_file(":/blue.qss"); if(!qss_file.open(QFile::ReadOnly)) { //qDebug()<<"qss file open error"; } qApp->setStyleSheet(qss_file.readAll()); qss_file.close(); }
标签:readonly only update turn open ado ati def col
原文地址:https://www.cnblogs.com/ike_li/p/12214824.html