MùPùF.org

Linux, Programming and Octopodes

--- *Projects* (website in development: svn r299)--- » PPassKeeper » ArduIDE

Steve Dodier-Lazaro's blog Steve Dodier-Lazaro's blog subscribe

Programming

Showing articles in category: (See all)

Programming

How-to: Use Graphviz to draw graphs in a Qt graphics sceneHow-to: Use Graphviz to draw graphs in a Qt graphics scene

in Programming
Tags: developmentgraphqtresearchtutorial

Well, it's been a long time. This post will be dedicated to explanations on how to draw graphs in Qt's QGraphicsScene, using GraphViz. We're not talking about rendering an SVG graph with GraphViz and then printing it in a scene, however. What we will do, instead, is:

  • represent a graph, using a C++ wrapper class for libgraph
  • tell GraphViz to compute positions for each node, and the path of each edge
  • draw our graph using QGraphicsEllipseItem and QGraphicsPathItem

The whole thing is used in a computer security research project on which I'm not allowed to give any information, so I will be vague on some parts of this tutorial, and I will not provide a whole bunch of ready-to-run code. I'm still going to give you the hints for fulfilling the three tasks above, and I will publish the class I wrote for my project (it is, of course, not generic at all, since it was designed for my particular needs).

This tutorial assumes you have a decent knowledge of how Graphviz works, and basic knowledge of the QGraphics API.

Published July 8, 2010 by read more
1