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

Andreas Pakulat apaku at gmx.de
Fri Mar 13 18:42:17 CET 2009


On 13.03.09 08:46:07, Scott Aron Bloom wrote:
> > -----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?
> 
> 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...

Hmm, interesting because thats exactly what the chart example in
examples/itemviews/chart does. Granted its not the most complicated model
that exists, but if something breaks on larger models than that would be a
bug in Qt. Or if QItemSelectionModel indeed was designed to be specific to
a given view then the API is flawed as it allows for this to happen.

Andreas
 
-- 
You don't become a failure until you're satisfied with being one.



More information about the Qt-interest-old mailing list