Get the name of current app style sheet in PyQt

一世执手 提交于 2019-12-31 07:37:04

问题


How can I get the name of current style sheet of my PyQt app?

app = QtGui.QApplication.instance()
print app.styleSheet()

app.styleSheet() returns nothing.

app = QtGui.QApplication.instance()
print app.style()

return <PyQt4.QtGui.QCommonStyle object at 0x0000000019BB4678>

I need a string, for example 'plastique'


回答1:


You can get the class name of the current style, if that's what you're looking for.

print app.style().metaObject().className()



回答2:


Qt does not use stylesheets for rendering of GUI. When you set up a stylesheet Qt generates corresponding QProxyStyle and use it. It is not possible to reverse this operation. When stylesheet is not set - then Qt may use native OS API for rendering controls.



来源:https://stackoverflow.com/questions/24012777/get-the-name-of-current-app-style-sheet-in-pyqt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!