PDA

View Full Version : How to save Qt Graphs as images without a graphical environment



Stophe
9th September 2020, 15:48
Hi !
I work on linux (Xubuntu), I think the graphical environment is handled by X11.
The problem I have is I sometimes launch big computations on a distant machine, so I do it by command line.

I would like to be able to plot 3D graphs (and benefit from the power of Qt DataVisualization), and print them to images, without having to launch a graphic interface (and so without a QApplication)... but I'm not sure it's possible.
I'm trying to look at QPixmap::grabWidget or QScreen::grabWindow, but the latter one requires a screen display, I think.
Do you have any options ?

Thanks !

d_stranz
9th September 2020, 17:08
I'm not sure it's possible.

I don't think it is possible. In order to create any Qt graphics, at a minimum you need a QApplication with an event loop running, and Qt Data Visualization probably depends on have a GUI-based app since it is based on OpenGL. And since it is OpenGL-based, it isn't obvious how you would render graphics to a file.

ChrisW67
11th September 2020, 22:51
In the good old days you could use Xvfb to provide a headless machine with a memory-only X11 screen to render on. Xvfb does not support OpenGL in any fashion IIRC.
You may have some luck with Xdummy (http://xpra.org/trac/wiki/Xdummy). Performance will not be great if it works at all (software GL).

I am assuming the volume of the raw data is too large pull it to your machine for processing and visualisation. Can you remotely digest the data into a more manageable set (compute on remote), transfer that result set over the network, and then render locally?

Stophe
22nd September 2020, 14:34
Thanks for your answers !
I have already different ways to transfer data, a few Go sometimes, but if I needed I could export only the part I need and it could work, don't worry about that. I just wanted to find a workaround to print 3D images of the data quickly with the same camera parameters for all my experiences rather than having just a screen print of such images.
By the way, I also wonder if it's possible to do it automatically with a graphical environment for a large number of images, but I did not start to work on that, so I'll explore that when I need it (my guess is setting the parameters, showing the window, grabbing it and automatically closing it).

I'll come back if needed and I'll continue to check if you have other ways to do it, but I assume you're right when you say it doesn't look the right way to go.

If things get complicated, I'll try Xdummy !