[Qt-interest] QAbstractItemModel

TP paratribulations at free.fr
Sun Mar 29 22:09:27 CEST 2009


Arnold Krille wrote:

> Is your model empty when showing the view? I had/have the effect that when
> the model is empty, the top-level is folded. And the very top-level
> element doesn't have a button to unfold. So you have to call expand(...)
> or expandAll() after the first items in the tree appear...

No, my model was not empty. But your remark about expandAll has lead me to
the right path: I have remarked that expandAll() allowed to keep the
QTreeView up to date. So, after a struggle, I finally realized the source
of my problem was:
* a "setItemsExpandable( False )" and "setRootIsDecorated( False )", which
when combined prevent me from understanding anything (shame on me!).
* a bad application of endInsertRows(): I was calling it only when the index
was isValid(), i.e. for non top-level items.

Now it works like a charm, without emitting "layoutChanged()"!

Thanks a lot!

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