从外部qss文件读取pyqt样式表 [英] reading pyqt stylesheet from external qss file

查看:40
本文介绍了从外部qss文件读取pyqt样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一个 pyqt 样式表的 qss 文件,我应该如何调用文件内容并提供给 self.setStylesheet(..)

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 ?

推荐答案

好吧,我自己想出了答案希望对大家有帮助:

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

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

这篇关于从外部qss文件读取pyqt样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆