user2391356
user2391356

Reputation: 81

QTableView force one cell selection

I want the user to be able to select only one cell at time. How can I set the maximum possible selection of cells of a QTableView to 1 (c++) ?

Upvotes: 0

Views: 453

Answers (1)

Lahiru Chandima
Lahiru Chandima

Reputation: 24068

Set selectionMode to SingleSelection and set selectionBehavior to SelectItems

enter image description here

tableView->setSelectionMode(QAbstractItemView::SingleSelection);
tableView->setSelectionBehavior(QAbstractItemView::SelectItems);

Upvotes: 1

Related Questions