1

I am new to Qt and C++... Now, I am writing an application in Qt, in which I have to display an already generated .dot file inside my application. I tried the render function but did not work for me.. Can anyone out there help me in this regard..

Thanks

tux
  • 1,730
  • 1
  • 15
  • 19

3 Answers3

2

Had the same problem using Python. I came up with this solution:

svg_string = dot_graph.create_svg(prog='dot')
svgWidget = QtSvg.QSvgWidget()
svgWidget.load(QtCore.QByteArray(svg_string))

Guess you can do something similar in C++

elgehelge
  • 2,014
  • 1
  • 19
  • 24
1

Plotting directly a dot file requires to be able to display the nodes in the correct positions, and link them properly. This is done by very complicated engines and is not included in the dot file, which is simply a description of the graph. Maybe there are C++/Qt libraries that take dot files as an input, but I don't know them.

According to this topic (Graphviz: How to go from .dot to a graph?), you can easily transform a dot file into a png or svg file. If you want to display the rendered graph into your application, the easiest thing to do is to generate that png picture (from the shell or from your code) and to manipulate it from your program.

Community
  • 1
  • 1
Bastien Pasdeloup
  • 1,089
  • 12
  • 19
  • Hi Bastien Pasdeloup, I agree with your post. But the actual solution I need is to make interaction with the rendered graph. If we convert to PNG or SVG then the interaction is not possible. So what is the possible way to make interactions with the output Graph ?? – tux Jul 16 '13 at 21:29
  • As I told you, I don't know any rendering engine in C++/Qt based on dot files. It might exist but I am not familiar with C++ libraries. You can try to find one, andit will certainly allow you to have some interactions with your graph. Another _overkill_ solution would be to import the graph as a picture, and to use some image recognition algorithms (goo.gl/VrCBy) to detect the location of the nodes/edges/information in order to allow interactions with your elements. If you choose this method, you should do some research about neural networs (goo.gl/i7Kbf) and Hausdorff distance (goo.gl/LZNSF) – Bastien Pasdeloup Jul 16 '13 at 21:54
0

Take a look to QGraph. You will need much more work to make your graphs interactive. Anyway, if you are new to Qt, even the simple display it's a steep introduction to graphics.

I have my own implementation, but I'm sorry it's not yet ready for publishing - I will do in a SWI-Prolog context...

CapelliC
  • 59,646
  • 5
  • 47
  • 90
  • Can you please suggest any libraires that we might use in order achieve our task?.. – tux Jul 23 '13 at 14:07