[Qt-qml] hasChildren attribute for Qml Model?
Martin Jones
martin.jones at nokia.com
Tue Apr 20 01:14:22 CEST 2010
On Mon, 19 Apr 2010 10:09:17 pm ext Stephen Kelly wrote:
> warwick.allison at nokia.com wrote:
> >> know whether a particular item hasChildren()
> >
> > Isn't this count>0? (it would be a little more efficient though if we had
> > an isEmpty or hasChildren)
>
> Nope. count is the number of items in a list. What I'm looking for is the
> number of children of a particular item in the list.
>
> The thing is the qml ListView has a QAbstractItemModel in it which is
> actually a tree.
>
> If you click on an item that has children, another part of the application
> should show the children. There needs to be some visual indication that a
> item in the list has children.
>
> In QTreeView, that's a [+] which you can click to expand.
You could add a Q_INVOKABLE method to your model to get the child count,
similar to the setRoot() method in this example:
http://qt.nokia.com/doc/4.7-snapshot/qml-visualdatamodel.html#rootIndex-prop
--
Martin
More information about the Qt-qml
mailing list