我只是想知道如何通过Pyqt中的QCheckBOx添加层叠菜单,以便对每个选择进行展开,并获得更多选项。下面是我的代码
class Example (QWidget):
def __init__(self, fname):
self.fname=fname
super().__init__()
self.initUI()
def initUI(self):
self.sheets= list(fname.keys())
print(self.sheets)
self.cb1 = QCheckBox("Hello", self)
self.cb2 = QCheckBox("You", self)
self.cb3 = QCheckBox("Are", self)
self.cb4 = QCheckBox("My", self)
self.cb5 = QCheckBox("Sunshine", self)
self.resize(300,400)
self.setWindowTitle('QCheckBox')
formLayout = QFormLayout()
groupBox = QGroupBox("This Is Group Box")
formLayout.addRow(self.cb1)
formLayout.addRow(self.cb2)
formLayout.addRow(self.cb3)
formLayout.addRow(self.cb4)
formLayout.addRow(self.cb5)
所以我有5个选择框
但是现在我想为每个框添加层叠菜单,就像下面的图片所示
假设您想要的内容已在eyllanesc's example中显示,但带有复选框,下面是此代码的一个版本,带有复选框,没有动画:
相关问题 更多 >
编程相关推荐