[英]QTableView advanced selection
I work with a QTableView and I would like to develop an advanced selection mode. 我使用QTableView,我想开发一种高级选择模式。 I have not managed to do it with
SelectionBehavior
nor with SelectionMode
. 我没有设法使用
SelectionBehavior
和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 编辑 - 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
. 我还尝试了
QAbstractItemView::ExtendedSelection
和QAbstractItemView::ContiguousSelection
。
Have you checked the signals from QItemSelectionModel, especially 您是否检查了来自QItemSelectionModel的信号,尤其是
[signal] QItemSelectionModel::currentColumnChanged
[signal] QItemSelectionModel :: currentColumnChanged
could be used to start a new selection in case the current selection would be extended to cover two columns. 可用于启动新选择,以防当前选择扩展到两列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.