[Qt-interest] QItemSelectionModel - how to ignore selection on column

Stephen Kelly steveire at gmail.com
Tue Sep 21 12:02:49 CEST 2010


David Boosalis wrote:

> I have a QTableView with two columns.  The first column contains a
> QStandardItem, the secone column contains a special widget with its own
> selectable items.

I don't understand. 

You have a QStandardItemModel and only put QStandardItem* into the first 
column, and you use setIndexWidget() to set widgets in the other column?

> 
> I would like to have the first column selection not be effected by any
> mouse
> clicks in the second column.  I do not see any methods for
> QItemSelectionModel to do this.  Any one have an idea on how to do this. 

Subclass QItemSelectionModel and reimplement both select methods to have the 
behaviour you want. Just ignore the parts of ranges with column > 0. 

> I do not want the second column to be disabled. I just want the multi
> selection in the first column not to be disrupted by what gets clicked in
> the second column.

Or maybe just reimplement flags() to make the item not selectable. I don't 
know if that will have any side effects.

All the best,

Steve.

> 
> Thanks for any help
> David





More information about the Qt-interest-old mailing list