Ok.

I thought the op was talking about viewing a C++ QAbstractItemModel in
QML without having to write the QML element himself in C++.

If it's a ListModel with ListElements your workarounds might work, but
good luck implementing proper keyboard handling in your first idea and
good luck getting the features you want in the second idea -
highlighting, current index, current item focus item N etc. It would
take a long time to finish that thing.

On Tue, Jan 25, 2011 at 8:56 AM,  <[email protected]> wrote:
> "It's not possible"? :)
>
> You can do this in all manners of ways, such as just taking a ListView and 
> making the delegates aware of what node in the tree they are rendering and 
> adjusting the indentation based on that. When a node is expanded or collapsed 
> you just update the list view model accordingly. If you want to keep it 100% 
> QML and JS then the tree view model can e.g. be a JSON structure with a flag 
> for each node that tells the TreeView whether the node is expanded or not.
>
> You can also do it on a lower level by creating a handful of items 
> (essentially tree view delegates) that you place inside a Flickable and move 
> around as the content is scrolled to simulate that there's really one for 
> each node. Then just figure out which nodes of the tree are visible and 
> update the items (tree view delegates) to reflect the correct content. 
> Especially if each node in the tree is rendered with the same height (same 
> delegate height) this is not too hard to do. The result is basically the same 
> as with the ListView.
>
> In any case it's not a great idea to recursively create items for the entire 
> tree (which it sounds like you were trying to do) since this will consume 
> huge amounts of memory and put a very tight limit on the maximum size of tree 
> that your component would be able to support.
>
> Peppe
>
> ________________________________________
> From: [email protected] 
> [[email protected]] on behalf of ext 
> Stephen Kelly [[email protected]]
> Sent: Monday, January 24, 2011 21:08
> To: [email protected]
> Subject: Re: [Qt-qml] Tree View In QML
>
> Ravindra Mitke wrote:
>
>> Hi guys,
>>
>> I want to create Tree View in Pure QML. I don't want to use QT code into
>> that.
>> Can you please suggest me the best way about doing this.
>>
>> Thanks in advance..:)
>>
>> *Thanks & Regards*
>> *Ravindra *
>
> It's not possible. I tried creating one by nesting an Item recursively to
> the depth of the tree, but the QML runtime sees that and stops you,
> complaining about infinite recursion.
>
> The options are
> - Write your own using c++
> - Use VisualDataModel and its drill down features.
>
>
> _______________________________________________
> Qt-qml mailing list
> [email protected]
> http://lists.qt.nokia.com/mailman/listinfo/qt-qml
>
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to