Reputation: 1367
I have custom table view that shows content of custom abstract model. I need to implement mixed selection for these view.
When user clicks on the first column the whole row should be selected (AbstractItemView::SelectRow). When user clicks on cell in other column just the particular cell should be selected (AbstractItemView::SelectItems).
What need to do to achieve such behaviour?
Upvotes: 2
Views: 349
Reputation: 18514
Just do this:
void MainWindow::on_tableView_clicked(const QModelIndex &index)
{
//if(!index.column()) more elegant
if(index.column() == 0)
ui->tableView->selectRow(index.row());
}
Catch clicked()
signal and check is it first column. If so, then selectRow()
with current row (index.row()
)
I use here QTableView
but QAbstractItemView
has clicked
signal too.
Upvotes: 1