[Qt-qml] Dynamically Create/Destroy Components With Properties

296 views
Skip to first unread message

Michael Dippold

unread,
Dec 29, 2011, 12:11:23 PM12/29/11
to qt-...@qt.nokia.com
I am currently having trouble with memory being freed in my QML application when I dynamically create and destroy components which contain custom properties.

Rectangle {
    property int myvar: 0
}

If the property does not exist, memory behaves normally.  Once the property is added memory keeps growing.  I just want to make sure I am not overlooking something.  I created a bug report a few weeks back (QTBUG-23024) but no updates yet.

Thanks,
Mike

Simon Gemmell

unread,
Dec 29, 2011, 9:27:59 PM12/29/11
to qt-...@qt.nokia.com
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

Simon Gemmell

unread,
Jan 8, 2012, 1:51:09 AM1/8/12
to qt-...@qt.nokia.com



From: gemme...@hotmail.com
To: qt-...@qt.nokia.com
Date: Fri, 30 Dec 2011 02:27:59 +0000
Subject: [Qt-qml] Model Based Trees in QML?
_______________________________________________ Qt-qml mailing list Qt-...@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)...

Sergiy....@nokia.com

unread,
Jan 9, 2012, 1:35:29 AM1/9/12
to gemme...@hotmail.com, qt-...@qt.nokia.com
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
Reply all
Reply to author
Forward
0 new messages