datainputHbox = QHBoxLayout()
layout = QVBoxLayout(self)
layout.addLayout(datainputHbox)
pagedatainputdeletboxbutton1.clicked.connect(lambda:self.boxdelete(datainputHbox))
def boxdelete(self, box):
这是PyQt程序 如何编写boxdelete函数以删除datainputbox表单布局。我试了很多。不过,我只能删除所有的小部件,但不能删除布局。
作为一般答案:taken from here有轻微但重要的更改:不应该调用widget.deleteLater()。至少在我的例子中,这导致了python崩溃
全局函数
与Brendan Abel's应答中的boxdelete函数一起
您可以通过获取它们对应的
QLayoutItem
并移除它来移除QLayouts
。您还应该存储对布局的引用,否则以后将无法访问它们,除非您知道它们所属的小部件。相关问题 更多 >
编程相关推荐