qt-interest@trolltech.com
[Top] [All Lists]

Re: QTreeView, QAbstractItemModel and adding a child...

Subject: Re: QTreeView, QAbstractItemModel and adding a child...
From: Benjamin Meyer
Date: Wed, 4 Jun 2008 16:22:21 +0200
On Tuesday 03 June 2008 20:29:50 Dave Thorup wrote:
> On Jun 2, 2008, at 10:55 PM, Benjamin Meyer wrote:
> > On Monday 02 June 2008 23:45:53 Dave Thorup wrote:
> >> Call beginInsertRows(...)
> >> Add a new child to my internal data structure.
> >> Call endInsertRows()
> >
> > You only need to do these two, you don't need to emit the
> > dataChanged signals.
> >
> > I highly recommend you give the modeltest a whirl and see what it
> > finds in
> > your model.  It is able to catch a lot of common errors especially
> > in tree's.
> > http://labs.trolltech.com/page/Projects/Itemview/Modeltest
> >
> > -Benjamin Meyer
>
> I actually tried using the ModelTest before I posted and it didn't
> report any errors with my model, at least none that I can see (it's
> supposed to Assert on errors right?).  If I just leave it to the
> beginInsertRows(...) and endInsertRows() with no dataChanged signals
> and no layoutChanged signals then I still get the same behavior - the
> 'plus' doesn't appear until I click on the TreeView or it is repainted
> in some other way.
>
> If the above is the correct way to do it and my model is working
> correctly then it appears that there is a bug in the TreeView.
> --
> Dave Thorup
> Software Engineer
> http://bibblelabs.com

If the modeltests doesn't find any problems then making a small test case 
would be a good idea.  It might be worth taking a look at hasChildren to make 
sure that it is returning the correct value if you reimplement it.  Using 
layout changed does work because the tree completely re-layouts the items, in 
otherwords it is slow and should be avoided when doing simple row insertions.

-Benjamin Meyer

--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>