954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Getting TableView current index

Hi all! I have a question about PyQT4.
How can I get an index of current cell, in which the cursor is whitout clicking on it?
According to official documentation of QT there are only signals that send current index
when you click on it. But if you just enter the cell with navigation keys they don't work...
Is there a way to get the current index of TableView (not TableWidget) whitout clicking on it?

annndrey
Newbie Poster
5 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

I've found the solution!
The problem was that in QT4 there are a signal and a slot with the same name - currentChanged(QModelIndex, QModelIndex)
To obtain an index of current cell while moving through the table we have to add a selectionModel to our TableView:

selectionModel = QtGui.QItemSelectionModel(TableView.model())
connect(selectionModel, QtCore.SIGNAL("currentChanged(QModelIndex, QModelIndex)"), some_function)


Et voila, it works!

annndrey
Newbie Poster
5 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: