Question

I have 10 QTablewidgets. Each of the QTableWidget display different data. I want to get the name of the table widget that the last time user clicked ( on any of the cells).

Currently i tried putting all the tables in a list:

table1 = QtGui.QTableWidget()
table2 = QtGui.QTableWidget()
...
...
mytablelist = [table1,table2,....]

Using Signal and Slots I tried this:

for item in mytablelist:
    self.connect(item,QtCore.SIGNAL("cellClicked()"),self.Identify)

My Identify function is as below:

def Identify(self):
    sender = self.sender()
    print sender

As far as i understand, the sender() method should tell me which Qobject the signal is coming from.

I don't seems to get any output from Identify function. What is causing the problem and how do i fix it?

Is there any better approach to this problem?

Was it helpful?

Solution

I think i found the problem. It was the problem with the signal cellClicked() i used (i have no idea why).

So, I tried to use itemSelectionChanged() signal instead of cellClicked() i used in my question. It works fine now. After that i just used index() method to get the position of table in the tablelist.

tableindex = mytablelist.index(sender)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top