Have you checked the signals from QItemSelectionModel, especially
[signal] QItemSelectionModel::currentColumnChanged
could be used to start a new selection in case the current selection would be extended to cover two columns.
Question
I work with a QTableView and I would like to develop an advanced selection mode. I have not managed to do it with SelectionBehavior
nor with SelectionMode
.
The user shall be able to pick up some cells but only if they belong to the same column:
The icing on the cake would be to prevent the last row (yellow one) to be selected.
Is there any solution?
EDIT - 2013/03/05
I cannot get it work:
ui->table->setSelectionBehavior(QAbstractItemView::SelectItems);
ui->table->setSelectionMode(QAbstractItemView::MultiSelection);
connect(ui->table->selectionModel(), SIGNAL(currentColumnChanged(QModelIndex,QModelIndex)), ui->table->selectionModel(), SLOT(clearSelection()));
What's wrong with this code? I also tried QAbstractItemView::ExtendedSelection
and QAbstractItemView::ContiguousSelection
.
Solution
Have you checked the signals from QItemSelectionModel, especially
[signal] QItemSelectionModel::currentColumnChanged
could be used to start a new selection in case the current selection would be extended to cover two columns.