0
我是Pyhthon和Qt的新手,因此这个基本问题。我想要的是,当我点击QTreeWidget中的一个项目时,会调用一个事件处理程序,它告诉我哪个项目已被点击。我试过的代码是:如何在PyQt4的点击反应QTreeWidget
self.dir_tree = QTreeWidget()
self.dir_tree.setColumnCount (3)
self.dir_tree.setHeaderLabels (("File", "Type", "Size"))
self.dir_tree.connect (dir_tree, SIGNAL ("itemClicked (QTreeWidgetItem*, int)"), self.onClickItem)
def onClickItem (self, column):
print (column)
这不运行,错误代码是:
TypeError: arguments did not match any overloaded call:
QObject.connect(QObject, SIGNAL(), QObject, SLOT(),Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'function'
QObject.connect(QObject, SIGNAL(), callable, Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'function'
QObject.connect(QObject, SIGNAL(), SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'function'
我在做什么错?还有一个与此有关的问题:我怎么才能找出哪个项目被点击?
我找不到这个教程,任何建议是值得欢迎的。
感谢您的任何帮助。