I am new to Pyhthon and Qt, hence this basic question. What I want is that when I click an item in a QTreeWidget an event handler is called which tells me which item has been clicked. The code I tried is:
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)
This does not run, the error code is:
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'
What am I doing wrong? And a question related to this: how can I figure out which item was clicked?
I could not find a tutorial for this, any suggestion is welcome.
Thanks for any help.