QTableView selected element in PyQt4
-
09-09-2019 - |
Question
Is there some way to read which row of Qt's QTableView
widget is selected by user? Does it have something to do with QModelIndex
class?
Solution
Yes, you can use QTableView::selectionModel()
(an inherited function from QAbstractItemView
) which returns you a QItemSelectionModel
. You then can call QItemSelectionModel::selectedIndexes()
, which returns a list of QModelIndex
es.
For reference, see QAbstractItemView::selectionModel()
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow