How to display a tree by using Qt
-
Hi all,
I'm newbie with qt. I don't know how to display a tree like the following image.!http://reference.wolfram.com/mathematica/ref/Files/TreePlot.en/O_1.gif(Tree)!
Which graphic library that we will use? And how to use it?
Thank any suggestion. -
Looks like the elastic nodes example :
"Link ":http://developer.qt.nokia.com/doc/qt-4.7/graphicsview-elasticnodes.html -
I don't know about a graphic library for painting trees but you could try to do it yourself, maybe defining levels.. dynamic arrays of dynamic arrays, and you then when you know how many items are on each level you can draw points like 1=0, 2=30,3=60..
@
for (int var=0;var < level[1].count;var++){
//DRAW item(30,var*30)
}@What I'm trying to say is that you can move 30px every time you draw a new item.
and to draw the lines I thnik that you could use the example elastic nodes.. hope that helps..
-
"GraphViz":http://www.graphviz.org/Documentation.php comes to mind. Not really a Qt related question though, if you ask me.
-
Um.. well.. it depends on what you have already. If you have the parent/child relationship in a datastructure (a C++ tree).. and your own algorithm to spread them out in a way it looks good.. then you can just use QPainter's drawPoint() and drawLine() or a QPainterPath. But if you need a framework which you can use to automagically generate the points visually for the tree.. I don't think Qt provides it.