11

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 ?

Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197

1 Answers1

30

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

sshFile="darkorange.stylesheet"
with open(sshFile,"r") as fh:
    self.setStyleSheet(fh.read())
Avaris
  • 35,883
  • 7
  • 81
  • 72
Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197
  • 2
    You don't need to make it a `QString` and better to close the `fh` or use `with`. I've edited your post. – Avaris Jan 24 '13 at 21:01