There are several options here. Either you need a Qt Console Application or you need a headless GUI Application.
You will find truly running a GUI in headless mode rather tricky. This applies in case you need to run the very same app in a Linux system which does not have the installed GUI libraries, like a minimal setup. Without extensive xorg and/or EGL libraries you'll find it impossible.
But fear not, you can do it with minimal impact by using either the Qt VNC platform plugin or with with the help of Xvfb. So in short
Solution 1: Hide it with Qt's VNC plugin
$ QT_QPA_PLATFORM="vnc" ./my-app
it's the same as
$ ./my-app -platform vnc
You'll find that you software has a GUI but it's running in headless mode, in order to view the GUI you just connect to it with any vncviewer.
Solution 2: Avoid dependencies with Qt's VNC plugin
The same as the other solution, and you can just hide your GUI by not showing it.
Solution 3: Nullify render with offscreen render
This is rather similar to VNC but you'll get a totally null output, no way for GUI interaction:
$ ./my-app -platform offscreen
Solution 4: Run Xvfb and launch it there
You can run a fake Xorg server and run things over there.
export DISPLAY=:1
Xvfb :1 -screen 0 1024x768x16 &
./myapp &
From the given solutions I'd prefer the offscreen render, but your Qt compilation might not have the plugin or it might ask for xcb or egl libraries. It's your choice.
QCoreApplication
instead?QStyle
(orQCommonStyle
) that renders nothing and set that withQApplication::setStyle(new CustomStyle);
beforeQApplication app(argc, argv);
could be an option?QApplication
do you need in head-less mode which are not provided byQCoreApplication
? If head-less is an essential requirement for your application, then you might also re-design your application to separate the parts needed for head-less and the parts for GUI respectively.