My program can run on a server with no GUI, or on a desktop. When it runs on a system that can display GUIs I want to instantiate QApplication, and when it is on a server I want QCoreApplication.
If I instanciate QApplication on a server, it either Segfault (at least it used to), or display an error message and exit, without letting me the chance to instantiate QCoreApplication instead:
This application failed to start because it could not find or load the Qt platform plugin "xcb". Available platform plugins are: linuxfb, minimal, offscreen. Reinstalling the application may fix this problem.
Seriously ?
Currently I just pass a -noGui argument when I run my program on a server. It works fine, but I want to detect if the system can use QApplication or not, so I can get rid of this argument.
I am sure there is already an answer to that somewhere, but I can't get a hand on it.