Visualise a data structure (Tree) in a QGraphicsScene



  • Hi all!

    I am developing a small application in witch I have to construct a tree of data then transform it to a graphic (root node, vertices and edges) using the GraphicsView framework.

    any idea, how to do that ?

    thanks in advance.



  • GraphicsView doesn't offer any ready-made items for a tree.

    You can try inserting a QTreeView or QTreeWidget as a QGraphicsProxyWidget into the scene.
    Pros: Use of an existing widget
    Cons: Performance. Probably some pitfalls when using QGraphicsProxyWidget that I don't know about.

    You can compose everything yourself, using Lines, Rectangles and Text.
    Pros: High performance, looking exactly the way you want
    Cons: A lot of work



  • Hi,
    Well it's not exactly a tree, It's an oriented graph : "the reachability graph of a Petri Net":http://en.wikipedia.org/wiki/File:Reachability_graph_for_petri_net.png !

    I begin by drawing a Petri Net in a QGraphicsScene then building the graph !

    please any help !



  • Take a look at the ElasticNodes and the DiagramScene samples (under graphicsview). Between the two, you should find pretty much everything you need.


Log in to reply