[Qt-interest] QAbstractItemModel

TP paratribulations at free.fr
Sun Mar 29 18:46:41 CEST 2009


Scott Aron Bloom wrote:

> You are not requried to implement the insertRows...
> 
> However you ARE required to call beginInserRows and endInsertRows (as
> well as the remove)
> 
> You shouldn't call layoutChanged()
> 
> The issue is the model has changed but the view thinks it's the same...
> so it doesn't bother to request the childcounts and everything else.

Thanks for the hint. So I have called beginInsertRows(...) and
endInsertRows(...) before adding one or more children.

The result is that now, without calling layoutChanged(), the added items
below existing top-level items (i.e. below the root node) appear in the
QTreeView. Before adding beginInsertRows(), etc. to my code, I was required
to emit the signal layoutChanged() to see these items.

But there remains a problem with top-level items, and all the items below
the top-level items:
* they never appear (neither the top-level items nor their children),
whereas I do beginInsertRows(), etc.
* when additionnally to beginInsertRows(), etc., I emit layoutChanged(), the
added top-level items appear, but not their children.

Any idea?
I sweat a lot on this topic.

Julien
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\
9&1+,\'Z4(55l4('])"

"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)




More information about the Qt-interest-old mailing list