我将一个单独的 qss 文件连接到 Pyside
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = App()
File = QtCore.QFile("styles/styles.qss")
qss = QtCore.QTextStream(File)
app.setStyleSheet(qss.readAll())
window.show()
sys.exit(app.exec_())
qss内容
QListWidget, QListView, QTreeWidget, QTreeView {
outline: 0px;
}
QListWidget {
min-width: 120px;
max-width: 120px;
color: white;
background: black;
}
QListWidget::item:selected {
background: rgb(52, 52, 52);
border-left: 2px solid rgb(9, 187, 7);
}
HistoryPanel::item:hover {background: rgb(52, 52, 52);}
QStackedWidget {background: rgb(30, 30, 30);}
QLabel {color: white;}
我收到一个错误
QIODevice::read (QFile, "styles/styles.qss"): device not open
文件就位,一切正常。我不明白怎么了
因为
QFile您必须首先使用模式的强制性指示调用open :从 python中使用open更容易:
都想通了