我有一个循环。我创建了一个QCheckBox并将它放在一个QTableWidget单元格中,一切都很好。在循环的每个步骤中,我connect为 myslot SLOT 调用了一个函数,但只QCheckBox应用了最后一个实例。我google了很多,发现很多人都有我的问题。我已经应用了他们的解决方案,但我的问题仍然存在。
for row in xrange(len(uniqueFields)):
instance = QtGui.QCheckBox(uniqueFields[row], findInstance.tableWidget)
print QtCore.QObject.connect(instance,
QtCore.SIGNAL(_fromUtf8("stateChanged (int)")),
lambda: findInstance.projectsInstance.myslot(
"TWCH", findInstance, instance.text(),
instance.checkState(), instance))
findInstance.tableWidget.setRowCount(findInstance.tableWidget.rowCount() + 1)
findInstance.tableWidget.setCellWidget(row, 0, instance)
注意:我的connect函数 return True。
如何connect在枚举所有的循环中创建函数instances?