PDA

View Full Version : QTableView: Select multiple rows?



realdarkman71
9th December 2010, 18:49
Hi all,

I have a QTableView and need more than one row selected.


void QTableView::selectRow(int row)

selects one row olny, and


ui->tableView->selectRow(0);
ui->tableView->selectRow(1);
ui->tableView->selectRow(2);


selects row 3 only!

Is there a way to select more than one row together?

Thx!
Chris

franz
9th December 2010, 20:00
You have to set the selection mode to the appropriate value. See the documentation (http://doc.trolltech.com/latest/qabstractitemview.html#SelectionMode-enum).

I'm not exactly sure if selectRow() will keep the other rows selected. If not, you'll have to learn about the selectionModel() (QItemSelectionModel).

realdarkman71
9th December 2010, 21:36
tableView->setSelectionMode(QAbstractItemView::MultiSelection );

that's it! Thanks for the hint!