Results 1 to 4 of 4

Thread: How to save Qt Graphs as images without a graphical environment

  1. #1
    Join Date
    Jul 2020
    Posts
    11
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default How to save Qt Graphs as images without a graphical environment

    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 !

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to save Qt Graphs as images without a graphical environment

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    Stophe (22nd September 2020)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to save Qt Graphs as images without a graphical environment

    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?

  5. The following user says thank you to ChrisW67 for this useful post:

    Stophe (22nd September 2020)

  6. #4
    Join Date
    Jul 2020
    Posts
    11
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default Re: How to save Qt Graphs as images without a graphical environment

    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 !

Similar Threads

  1. QTextEdit save as RichText width Images
    By kea_ in forum Qt Programming
    Replies: 2
    Last Post: 9th August 2010, 08:53
  2. Save images directly into mysql with qtcreator
    By Lycus HackerEmo in forum Qt Programming
    Replies: 1
    Last Post: 17th January 2010, 09:29
  3. Replies: 4
    Last Post: 27th July 2009, 16:45
  4. Open/Save dialog with images preview
    By mchara in forum Qt Programming
    Replies: 8
    Last Post: 5th November 2007, 08:25
  5. Save images to database
    By jnk5y in forum Qt Programming
    Replies: 4
    Last Post: 8th May 2006, 20:56

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.