[Qt-interest] Creating a QModelIndex outside ofa QAbstractItemModel subclass

Scott Aron Bloom Scott.Bloom at sabgroup.com
Fri Mar 13 16:46:07 CET 2009


> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Andreas Pakulat
> Sent: Friday, March 13, 2009 6:53 AM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Creating a QModelIndex outside ofa
> QAbstractItemModel subclass
> 
> On 12.03.09 13:18:20, Dario Ahdoot wrote:
> > Yes, it doesn't select the whole row. However, if a view's style is
select
> the whole row, then selecting an index through the selection model of
the view
> should be identical to selecting that index through the UI itself, no?
i.e.
> the whole row of the index should be selected, I would think.
> >
> > If you select an item in a tree view where the selection behavior is
to
> select the whole row when you click on an item (or select it
> programmatically), it is weird to see the existing behavior, both from
a
> coders and UI point of view.
> 
> IMHO its not weird. See the selection model of a given view is just
another
> model. It doesn't know _anything_ about the view its attached to,
hence it
> cannot know that selecting an item in a certain row should be
selecting all
> items in that row.
> 
> Think about what happens if you have multiple views with the same
selection
> model, which view should "force its" selection behaviour on the
selection
> model? And why should this then also force the other view into the
same
> selection behaviour?
> 
> Andreas
> 
> --

But the selction model is a special model :)  And IIRC you may have your
own derived selection model, but unlike a the data models, I don't think
you can share selection models...  I had tried that back in 4.2, and was
told by support it cant be done...

I had 3 views of the same data (tree, table and graphical) and I wanted
to be able to select in one, and it auto select in  the others, so
sharing the selection model seemed to be the way to go... However, the
solution I wound up choosing was to connection the "item selected"
signals to "select items slots"...

Scott







More information about the Qt-interest-old mailing list