我需要知道每次单击QPushButton时如何添加一个新的组合框,我只创建了一个在组合框上创建的函数,当单击按钮时我需要向这个组合框显示多个,我该怎么做?
Yo
from PySide2.QtWidgets import *
def addButton(layout):
box = QCheckBox("Hi h !")
layout.addWidget(box)
if __name__ == '__main__':
app = QApplication(sys.argv)
widget = QWidget()
lay = QGridLayout()
widget.setLayout(lay)
btn = QPushButton("Press me")
lay.addWidget(btn)
btn.released.connect(lambda: addButton(lay))
widget.show()
sys.exit(app.exec_())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.