[Qt-interest] Qt-based Tree container?

Malyushytsky, Alex alex at wai.com
Thu Oct 29 00:44:37 CET 2009


Qt does not provide Tree-like container.
Main purpose of QT is to provide portable code mostly related to the GUI.
At least advanced data handling seems beyond QT goals.

More of that,AFIK stl does not provide such container either.

You may try to look at the 3rd party libraries if you really need it.
I don't have a lot of experience with such, but here are few links:

http://tree.phi-sci.com/
http://stlplus.sourceforge.net/stlplus/docs/ntree.html
http://www.boost.org/doc/libs/1_36_0/libs/graph/doc/index.html (graph)

In the most cases you can simply use std::map.
(Behind the hood most of the stl implementation of std:map use Red-Black tree)

Regards,
    Alex


-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of André Somers
Sent: Wednesday, October 28, 2009 12:11 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Qt-based Tree container?

Hi,

While I am sure your solution would work, I must say that I don't find it a
very elegant solution. Sure it's clever, but it also brings a lot of
unneeded overhead, and there are severe limitations. I am more looking for a
template based tree container (just like there is for lists, hashes, maps,
vectors...) complete with a nice set of iterators (depth first, breath
first, siblings only, etc.). Thanks for your input though.

André


-----Oorspronkelijk bericht-----
Van: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] Namens Arnold Krille
Verzonden: dinsdag 27 oktober 2009 14:30
Aan: qt-interest at trolltech.com
Onderwerp: Re: [Qt-interest] Qt-based Tree container?

On Tuesday 27 October 2009 11:15:51 Andre Somers wrote:
> With the talks about model/view programming still in my mind, and the
> remarks on how you should not use a model to actually store the
> information but only provide an interface to it comming back to
> memory, I wanted to refactor a model I have done in an application I am
working on.
> I find myself needing a generic tree implementation, and I realize
> that that is something I have been strugling with before when trying
> to implement tree models: trees are hard to get right...
> Looking through the Qt container classes, I was wondering why there
> isn't a QTree container class to store n-ary trees in a good way. I
> think that would be very useful to have in the toolkit. What do other
> people here use if they need to keep data in memory in a tree structure?
> Is there some Qt-ish generic implementation around I could use? Should
> it be added to the Qt container classes?

There is a Qt tree object, its called QObject :-)

My QTreeItem at
https://svn.fzd.de/trac/epos/browser/trunk/epos/libcore/qtreeitem.h just
extends that a little...
I also have a model to provide a tree-view on that trees:
https://svn.fzd.de/trac/epos/browser/trunk/epos/libcore/qtreeitemmodel.h

Arnold


_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list