[Qt-interest] Test for X server support where application is running?

Konrad Rosenbaum konrad at silmor.de
Wed Aug 19 19:52:14 CEST 2009


On Wednesday 19 August 2009, Ed Sutton wrote:
> I want my application to not display the GUI window if for example, it
> is running in an ssh shell.  Is there a way for an app to test if it
> has X server support?

Test for the DISPLAY environment variable (man getenv). If it exists and is 
not empty, it means you probably have an X environment. However, you can't 
easily find out whether that environment is tunneled through a ssh 
connection.

Please be aware that you also have to instantiate a QCoreApplication if you 
don't want X (because QApplication probes for X and aborts the application 
if it isn't there), and you need a QApplication if you want GUI.

It might be easier to create two different applications that share some of 
the code.


	Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090819/1050ccb6/attachment.bin 


More information about the Qt-interest-old mailing list