Q Table Widget issues emitting signal when data has been changed

821 views
Skip to first unread message

Benjam901

unread,
Apr 14, 2015, 4:39:46 AM4/14/15
to python_in...@googlegroups.com
Hello all,

I am having a bit of trouble with my QTableWidget. When you double click and edit a text field inside the QTableWidget I need a signal to be emitted when enter is pressed/when the data in the table has actually changed.

My test case is self.uiMainWindow.uiExtensionTable

I have tried testcase.cellChanged, testcase.dataChanged and also something like this:

self.connect(self.uiMainWindow.uiUnitExtensionTable, QtCore.SIGNAL(self.uiMainWindow.uiUnitExtensionTable.itemChanged(self.uiMainWindow.uiUnitExtensionTable.currentItem)), self.testPrint) # Gives me native Qt signal is not callable Error

But I have have had no luck so far

cellChanged seems to be the closest I have gotten so far but it activates when I double click the item rather than when I have finished editing the text field.

Any help would be much appreciated :)

Cheers,

Ben

Marcus Ottosson

unread,
Apr 14, 2015, 5:04:08 AM4/14/15
to python_in...@googlegroups.com

Spontaneously, I’d adjust the old-style signal connection with the new-style method of connecting, maybe that will make things a little more clear what’s going on.

self.uiMainWindow.uiUnitExtensionTable.itemChanged.connect(self.testPrint)

Wasn’t sure about how to convert the other arguments, but this self.uiMainWindow.uiUnitExtensionTable.itemChanged is a signal that you are attempting to call directly, and is why you’re getting the error. If you’re looking to emit the arguments with it, you’ll need to pass them to .emit() instead.

self.uiMainWindow.uiUnitExtensionTable.itemChanged.emit(self.uiMainWindow.uiUnitExtensionTable.currentItem)

See here about old-style versus new-style.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e92615c3-c92f-464b-acde-487d50976d10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Ben Hearn

unread,
Apr 14, 2015, 5:27:22 AM4/14/15
to python_in...@googlegroups.com
Hello Marcus,

Thank you for your reply I have changed my signals and have set up a function that tests for current data vs old data only when the table has been populated.

Thank you for the help. For anyone who has a similar issue I have left my test function below. Test cases seem to be working so far

self.uiMainWindow.uiUnitExtensionTable.itemDoubleClicked.connect(self.testData)
self.uiMainWindow.uiUnitExtensionTable.itemChanged.connect(self.testPrint)

def testPrint(self):
try:
self.newData = self.uiMainWindow.uiUnitExtensionTable.currentItem().text()
row = self.uiMainWindow.uiUnitExtensionTable.currentItem().row()
print self.uiMainWindow.uiUnitExtensionTable.verticalHeaderItem(row).text()
print "Item changed"
 
if self.newData != self.currentData:
print "Old data", self.currentData
print "New data", self.newData
else:
print "No new data", self.currentData
except:
pass
 
def testData(self):
try:
print "cell entered"
self.currentData = self.uiMainWindow.uiUnitExtensionTable.currentItem().text()
except:
pass

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/yXV-Dg66jiU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODTWiZV%3D8EEcpPmaRwQcaSnqsFrRGYrgg_yen%2Bn%3DM853A%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--

Tel - +46 76245 92 90 (Sweden)

n.va...@gmail.com

unread,
Feb 9, 2019, 2:10:22 PM2/9/19
to Python Programming for Autodesk Maya
i am searching this solution on whole internet, finally found, phew
Reply all
Reply to author
Forward
0 new messages