render a gvc (graohviz) from c++ console application / or qt gui application

时间:2015-10-30 23:24:01

标签: c++ render graphviz

I am writing a programme which can generate dot desctiption file that I would like to directly on the screen. I got following code from graphviz.org on how to use it as a library and it works int main(int argc, char *argv[]) { Agraph_t* G; GVC_t* gvc; gvc = gvContext(); /* library function */ FILE* fl; FILE* ot; ot = fopen("/home/test.png", "w"); fl = fopen("/home/my.gv", "r"); G = agread(fl,0); gvLayout (gvc, G, "dot"); /* library function */ gvRender(gvc, G,"png", ot); gvFreeLayout(gvc, G); /* library function */ agclose (G); /* library function */ return (gvFreeContext(gvc)); } When I run it from the qt console application project, it just gives Press <RETURN> to close this window... I can see it does generate this test.png file. I am thinking there must be a way that I can show the gvc directly without like opening an png file, right?

1 个答案:

答案 0 :(得分:0)

Because writing a GUI application for this from scratch seems like an awesomely bad idea, how about using an external program to achieve this? You can even launch it from within your generating program if you insist: system("feh -dR1 test.png");