There is no simple mapping of tree like structures in QML (there is some 
support on the model side though). You have to do everything by hand. QML has 
list and list view, you have to start from there.
Check example here 
http://developer.qt.nokia.com/doc/qt-4.8/qml-visualdatamodel.html it shows 
directory structure using ListView.

:s

From: ext Simon Gemmell <gemmell...@hotmail.com<mailto:gemmell...@hotmail.com>>
Date: Sun, 8 Jan 2012 06:51:09 +0000
To: <qt-qml@qt.nokia.com<mailto:qt-qml@qt.nokia.com>>
Subject: Re: [Qt-qml] Model Based Trees in QML?



________________________________
From: gemmell...@hotmail.com<mailto:gemmell...@hotmail.com>
To: qt-qml@qt.nokia.com<mailto:qt-qml@qt.nokia.com>
Date: Fri, 30 Dec 2011 02:27:59 +0000
Subject: [Qt-qml] Model Based Trees in QML?

Hello,

I'm wondering how I could go about implementing a view of a C++ based tree such 
that the entire tree is shown. I've seen plenty where you can navigate the tree 
showing sections of it, but i want to see the WHOLE tree.

The complication is that I have a data structure in C++ land, and everything in 
the tree is an abstract "TreeNode" but there are 5 or 6 specialisations of 
TreeNode that represent different things. The tree is not a part of any of the 
Qt model frameworks (e.g. AbstractItemModel etc). Can QML handle recursive tree 
structures like that yet (each TreeNode has a list of child TreeNode's)? Is 
there some magical way to say "here is my tree of TreeNodes" and QML then knows 
how to layout and draw each concrete instance (e.g. TextTreeNode, ImageTreeNode 
etc)?

Can anyone point me in the right direction? I don't actually intend on drawing 
my tree like a QTreeView, it actually represents a document, but I am stuck on 
the first step of getting a C++ tree structure mapped to something in QML.

Any pointers you could provide would be of great help.

Thanks,
Simon

_______________________________________________ Qt-qml mailing list 
Qt-qml@qt.nokia.com<mailto:Qt-qml@qt.nokia.com> 
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

The only other thing I can think of is to not use QML at all and write one 
based on QAbstractScrollArea myself (I have already pushed QTextDocument to 
it's limits, it just isn't working for me)...
_______________________________________________ Qt-qml mailing list 
Qt-qml@qt.nokia.com<mailto:Qt-qml@qt.nokia.com> 
http://lists.qt.nokia.com/mailman/listinfo/qt-qml
_______________________________________________
Qt-qml mailing list
Qt-qml@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to