How to use Non-Standard Custom Font with Stylesheets?

后端 未结 1 815
情话喂你
情话喂你 2021-02-06 01:10

I have a PyQt4 application that is being styled by an external .qss file by using the following code:

...
app = QtGui.QApplication(sys.         


        
1条回答
  •  遇见更好的自我
    2021-02-06 01:40

    This is just a guess, because I cannot test it myself, but you could try loading the font before setting the stylesheet:

    app = QtGui.QApplication(sys.argv)
    QtGui.QFontDatabase.addApplicationFont('path/to/font')
    # or load the font data directly
    # QtGui.QFontDatabase.addApplicationFontFromData(fontdata)
    stylesheet = open('mystylesheet.qss').read()
    app.setStyleSheet(stylesheet)
    

    0 讨论(0)
提交回复
热议问题