pythonpyqt4pysidestylesheet

Reading pyqt stylesheet from external qss file


I have made a qss file of pyqt stylsheet and how am I supposed to call the file content and feed 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?


Solution

  • Figured out the answer:

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