QTableView高级选择
我使用QTableView,我想开发高级选择模式。我没有设法做到这一点SelectionBehavior
也没有SelectionMode
。QTableView高级选择
用户应能够拿起一些细胞,但只有当他们属于同一列:
- VALID行为:
- INVALID BEHAVIOR:
上锦上添花的是防止最后一行(黄色的)被选中。
有没有解决方法?
编辑 - 2013年3月5日
我无法得到它的工作:
ui->table->setSelectionBehavior(QAbstractItemView::SelectItems);
ui->table->setSelectionMode(QAbstractItemView::MultiSelection);
connect(ui->table->selectionModel(), SIGNAL(currentColumnChanged(QModelIndex,QModelIndex)), ui->table->selectionModel(), SLOT(clearSelection()));
有什么不对的代码?我也试过QAbstractItemView::ExtendedSelection
和QAbstractItemView::ContiguousSelection
。
你从QItemSelectionModel检查的信号,特别是
[信号] QItemSelectionModel :: currentColumnChanged
可以用来启动一个新的选择的情况下,当前选择将扩大到覆盖两列。
我还没有看到这个信号。这可能会有帮助,但是当这个信号发出时,如何取消不需要的单元格? – Maxbester 2013-02-28 08:24:13
您可能会取消选择到目前为止已选择的所有单元格,否则,可能很难取消选择某个选择并开始新的选择。因此,只需用户现在选择的单元格即可开始新的选择。 – Jens 2013-02-28 09:42:30
是的你说得对,谢谢。但我有一个问题。 '我的'QTableView'中的'selectionModel()'返回null。因此,我无法连接到'currentColumnChanged()'。这听起来很熟悉吗? – Maxbester 2013-02-28 10:00:56
相关问题:[如何限制QTableWidget中的选择](http://*.com/q/8658656/20984)。 – 2013-02-28 08:25:56
太棒了!谢谢!! – Maxbester 2013-02-28 09:23:47