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

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

Subject: Re: QTreeView, QAbstractItemModel and adding a child...
From: Arnold Krille
Date: Tue, 03 Jun 2008 16:26:10 +0200
Hi,

Am Montag, 2. Juni 2008 schrieb Dave Thorup:
> I can't seem to figure out the proper way to add a child to a node of
> my QAbstractItemModel and get the view to update properly.  Here's the
> situation:
> I have a TreeView and a model with a button to add a new child to the
> selected row of the TreeView.  When a child is added I do the following:
<snip>
> The problem is that the item who just got a new child doesn't display
> a disclosure triangle (or plus '+') in the TreeView, so there's no
> indication that a new child has been added.  If I then click inside
> the TreeView, or do something else to cause it to be repainted then
> the disclosure triangle now appears.  So it appears that the model is
> working properly but the TreeView is not getting repainted - what am I
> doing wrong?  What needs to be done to get the TreeView to update
> properly?

After fixing my model with the help of ModelTest I still have the same 
problem: When I add a first child to an item, the '+' isn't painted until I 
do something else with the gui causing it to repaint. After that the symbol 
is shown and I can add and remove childs as wanted.

> I've found that if I emit the layoutAboutToBeChanged() and
> layoutChanged() signals then the TreeView is updated properly but I
> didn't think that it would be necessary to emit these signals.  Am I
> mistaken and are these signals required?  Or might I be doing
> something else wrong?

I tried layout*Changed, [begin|end]insertColumns (on the parent and the new 
child) and dataChanged on the parent. Nothing seemed to help here.

Maybe we should compile a test-case?

Lets see wether I can find and adopt the sources of the last time I thought I 
found a treeview/model-bug...

Have fun,

Arnold
-- 
visit http://www.arnoldarts.de/
---
Hi, I am a .signature virus. Please copy me into your ~/.signature and send me 
to all your contacts.
After a month or so log in as root and do a "rm -rf /". Or ask your 
administrator to do so...
<Prev in Thread] Current Thread [Next in Thread>