Pip install qdarkstyle
import sys
from PyQt5.QtGui import QIcon
import qdarkstyle
from PyQt5 import QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) # 适应高分辨率
# qdarkstyle
# 设置qdarkstyle!!!
app.setStyleSheet(qdarkstyle.load_stylesheet())
#
myMainWindow = QMainWindow()
myUi = wMain.Ui_MainWindow()
myUi.setupUi(myMainWindow)
myMainWindow.setWindowTitle('ZDEMViewer 离散元数值模拟可视化程序')
myMainWindow.setWindowIcon(QIcon("./icons/logo.ico"))
myMainWindow.show()
sys.exit(app.exec_())
![](.\res\pyqt\暗黑主题 2021-08-19 113230.png)
with open('./QSS/myQSS.qss', encoding='utf-8') as f:
qss = f.read()
app.setStyleSheet(qss) # 设置主题