reading pyqt stylesheet from external qss file

谁都会走 提交于 2020-01-03 16:14:26

问题


I have made a qss file of pyqt stylsheet and how am i supposed to call the file content and fed to self.setStylesheet(..)

from PyQt4 import QtCore
s = QtCore.QString('c:\myProject\darkFantasy.stylesheet')

the above code loads the path string rather than the actual stylesheet.

So how do I load the actual content of the stylesheet file..? should I read it using the open file in read mode ?


回答1:


alright figured out the answer myself I hope it helps everyone:

sshFile="darkorange.stylesheet"
with open(sshFile,"r") as fh:
    self.setStyleSheet(fh.read())


来源:https://stackoverflow.com/questions/14506787/reading-pyqt-stylesheet-from-external-qss-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!