链接:
https://github.com/ColinDuquesnoy/QDarkStyleSheet
用法:
下载/克隆项目并将以下文件复制到应用程序目录(保留现有目录层次结构)。将主题替换为您需要使用的当前可用(深色/浅色)主题。
将 qdarkstyle/theme/style.qrc 添加到 .pro 文件中
RESOURCES += qdarkstyle/theme/style.qrc
然后可以看到有如下文件结构:
在main.cpp文件中添加如下代码,运行项目,生成该风格:
QFile f(":QDarkStyle/qdarkstyle/dark/darkstyle.qss");
if (!f.exists()) {
printf("Unable to set stylesheet, file not found\n");
}
else {
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
}