[Qt-interest] Qt-based Tree container?

André Somers andre at familiesomers.nl
Wed Oct 28 08:10:56 CET 2009


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





More information about the Qt-interest-old mailing list