[Qt-interest] how to prevent selecting multiple columns in a QTableView

Sean Harmer sean.harmer at maps-technology.com
Thu Oct 28 17:29:45 CEST 2010


Hi,

On Thursday 28 October 2010 16:24:45 Andy Hirsh wrote:
> Hello Samuel
> 
>   mmm... maybe I'm doing something wrong, but I was not able to set this
> behaviour using the two functions you talk about; what I need is to allow
> multiple item selection, but only if they are on the same column.
> 
> note that setting:
> 
>    tableView->setSelectionBehavior(QAbstractItemView::SelectColumns);
> 
> will select always the entire column, while I want to be able to select
> only part of it...

You may need to create a new view that inherits QTableView and add a new 
selection behaviour that does what you need in this case since none of the 
standard ones support quite what you need (I think).

Or even better, file a merge request through gitorious that adds this mode to 
the standard QTableView as I can see times when it would be handy. This way, 
everybody will benefit from it.

Good luck,

Sean




More information about the Qt-interest-old mailing list