PyQT

如何给QPushButton的click事件的响应函数传入参数?

使用lambda,实例代码:
buttonChangeSetting.clicked.connect(lambda : self.showRoleSettingDialog(unicode(treeItem.text(0)), unicode(treeItem.text(1)), unicode(treeItem.text(2))))

    def showRoleSettingDialog(self, roleId, roleName, activeTask):
        self.dialogRoleSetting.show()


如何往QTreeWidget的TreeItem传入用户数据(类似MFC的UserData)?

设置部分:
treeItem = QtGui.QTreeWidgetItem(groupRoot, [str(role.id), role.name, role.currentTask, '', u"dl", u'0'])
treeItem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(str(role.id)))


读取部分:
roleId = treeItem.data(0, QtCore.Qt.UserRole).toString()

你可能感兴趣的:(qt)