[Qt-creator] EnvironmentModel class

Daniel Teske daniel.teske at nokia.com
Thu Feb 12 12:10:07 CET 2009


> int EnvironmentModel::rowCount(const QModelIndex &parent) const
> {
>     if (parent.isValid())
>         return 0;
>
>     return m_mergedEnvironments ? m_resultEnvironment.size() :
> m_items.count(); }
>
> Shouldn't it be !parent.isValid()?

No. 

Essentially, the structure looks like this:

rootIndex <--- invisible root, invalid
 |--> child1 <--- actual visible, valid
 |--> child2 <--- actual visible, valid

And since child1 and child2 don't have any children, after all it is a flat 
list, we need to return 0 for valid indexes, and whatever the count of items 
is for the invalid rootIndex.

daniel



More information about the Qt-creator-old mailing list