3
votes

I have a table with some data that I want to be able to edit through the QTableWidget. Upon trying to connect the currentItemChanged signal:

self.QTableWidget.currentItemChanged(QTableWidgetItem,QTableWidgetItem).connect(self.editCell)

I get the following error:

'TypeError: native Qt signal is not callable' 

I went looking in to the QtDesigner, where you can connect signals. I made a QTableWidget, and connected it to a label so that changing the currentItem hid the label.

In the signal connecting dialog the currentItemChanged signal was written thus:

currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)

I don't know what the * means, but I assume it's important.

Am I using the wrong signal or is my syntax wrong somehow? In short, I want there a signal to be emitted upon changing any particular item/cell(I'm not sure what the distinction is)

____________________EDIT_________________________

EDIT: In the QTableWidgetItem class documentation I also found that it has functions column() and row().

I tried adding them like this:

self.QTableWidget.currentItemChanged(QTableWidgetItem.column(QTableWidgetItem.column()),QTableWidgetItem.row()).connect(self.editCell)

But got the error:

TypeError: descriptor 'column' requires a 'PySide.QtGui.QTableWidgetItem' object but received a 'Shiboken.ObjectType
1

1 Answers

1
votes

This bit is concerning:

self.QTableWidget

If your table is literally called "QTableWidget" there may be confusion later on. Specifically, the error you are getting makes it look like you are calling QTableWidget.currentItemChanged.

Also, its worth reviewing the PyQT documentation on "new-style signals", specifically on dealing with overloads to understand how it all works. Fortunately however, QTableWidget.currentItemChanged isn't overloaded so, the code you should be using should just be:

self.yourTable.currentItemChanged.connect(self.editCell)

Regarding your later edits, in this code:

currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)

The QTableWidgetItems that are being parsed are arguments that are given to the signal. You can't change them, as they are definined in the method that defines the slot, and passed when the signal is fired. From the documentation linked above:

void currentItemChanged (QTableWidgetItem *,QTableWidgetItem *)

This signal is emitted whenever the current item changes. The previous item is the item that previously had the focus, current is the new current item.