reading pyqt stylesheet from external qss file

Ciasto piekarz picture Ciasto piekarz · Jan 24, 2013 · Viewed 10.1k times · Source

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 ?

Answer

Ciasto piekarz picture Ciasto piekarz · Jan 24, 2013

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

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