【发布时间】:2020-11-10 08:46:21
【问题描述】:
我想将图像添加到我的按钮。我的所有样式都在一个单独的文件中。
根据 Qt docs https://doc.qt.io/qt-5/stylesheet-syntax.html#selector-types 我应该能够使用以下语法访问特定按钮
QPushButton#my_button_name {}
但它似乎不起作用。 这是我的代码中的一个示例:
# script with widgets and layouts
class Tab1():
self.button1 = QPushButton()
# styling script
def button_style():
return '''QPushButton#button1 {font:15px;}'''
我误会了什么?我尝试添加“自我”。到样式脚本中的名称,但它也不起作用。
【问题讨论】:
标签: python pyqt pyside2 qtstylesheets