How to Set the Focus to a moved up Row in QTableView
-
I have a QTableView with 3 rows and 2 columns. I want to a Move Up / Move Down a Single Row when a Push Button is clicked, I can Move Up / move Down a Single Row when a Push Button is clicked. But the Focus Remains at the same cell. I want to move the Focus of the item which has Moved up / Moved Down.
EDIT : I will explain it clearly, My TableView Consists of (ex. ) 3 Rows. Now, if i select the 3rd Row and if i click the Move Up button then the 3rd Row item has to move up to the 2nd Row. And if i click the Move Up button again, the 2nd Row Item should Move Up to the 1st Row.
-
I guess you should ask the selection model of the tableview to "set the current index":http://qt-project.org/doc/qt-5.1/qtcore/qitemselectionmodel.html#setCurrentIndex to whatever row you wish. As far as I know there is no "focus" obtainable by a cell inside a view, so I assume what you mean is the "current" status - that adds a dotted line around an item.