1 回答

TA貢獻(xiàn)1770條經(jīng)驗(yàn) 獲得超3個(gè)贊
您可以使用自定義角色來存儲(chǔ)對(duì)象:
ObjectRole = QtCore.Qt.UserRole + 1000
Class fcGui(QtGui.QWidget):
def initUI(self):
self.listWidget = QtGui.QListWidget(self)
self.objData = []
self.listWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
for obj in App.ActiveDocument.Objects:
it = QtGui.QListWidgetItem(obj.Name)
it.setData(ObjectRole, obj)
self.listWidget.addItem(it)
def acceptance(self):
for it in self.listWidget.selectedItems():
obj = it.data(ObjectRole)
print(obj, obj.Name)
添加回答
舉報(bào)