Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get selected rows in QTableView

Tags:

row

qt

qtableview

After watching many threads about getting selected rows numbers, I am really confused.

How do you get ROW numbers in QTableView using QStandardItemModel I used below selection model and behavior as

setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::SingleSelection); 

and if you have your own way of selecting can you explain how it works. Thanks for the help!

like image 361
shett73 Avatar asked May 08 '11 12:05

shett73


1 Answers

The method selectionModel() return a QItemSelectionModel.

You can use QItemSelectionModel class to check/change/other selection(s)

Example:

QItemSelectionModel *select = table->selectionModel();  select->hasSelection() //check if has selection select->selectedRows() // return selected row(s) select->selectedColumns() // return selected column(s) ... 
like image 72
Luca Avatar answered Oct 12 '22 08:10

Luca