I’ve just started to work with python, so I run into problem. I’ve searched everywhere, and I’ve come to this: I made a simple GUI using QT-Designer. After tableWidget is filled out all I want is to automatically scroll to row 10 , which I succeeded like this:
for i in range(0, self.rows):
...filling table...
self.ui.tableWidget.scrollToItem(self.ui.tableWidget.item(10, 3), QtGui.QAbstractItemView.PositionAtCenter)
self.ui.tableWidget.scrollToItem(self.ui.tableWidget.selectRow(10), QtGui.QAbstractItemView.PositionAtCenter)
Problem: this doesn’t work without line 3 or 4. As I said, I’m new at Python, so the good explanation or suggestion would mean a lot to me.
So, this line:
Will work, because you’re getting an item back as the result of doing self.ui.tableWidget.item(10, 3)
This line won’t work – because what it looks like you are trying to do here is select the row in the interface, which has a None (void) value return
You have to do both calls, 1st scroll to the item, then select the row (or whichever order you want, doesn’t matter the order)
In C++ you’d get an error, but in Python a void returned method will return you None, which is the same as passing a NULL pointer into the scrollToItem method.