PDA

View Full Version : program cannot connect to X server



Wazman
1st September 2009, 18:06
I have written rather simple application that parses a data file then based on the command line arguments set by the user the app will generate a plot (using the qwt lib) and saves it as a .png file. The plot is never displayed by the actual application. The purpose of the app is to only parse and generate the .png file.

How the plot application is even called is a slightly more complicated matter. The user interface is provided through a web browser that eventually passes the desired settings to a python script that actually calls my executable.

The problem I have is that instead of a .png file being generated the following debug statement is displayed on the webpage

dwp: cannot connect to X server

I really have no idea how to fix this. I'm trying to demonstrate the power and usability of Qt and the derived libraries to my co-workers.

caduel
1st September 2009, 18:54
a guess: see the QApplication constructor that takes a bool (3rd arg) to disable a gui.

Otherwise creating a QApplication will (under X11) cause Qt to try to open a connection to an X server.

Wazman
1st September 2009, 19:04
That seems to be a step in the right directionI've changed the app line in my main to the following.

QApplication app(argc, argv, QApplication::Tty);

I'm not getting the 'cannot connect to X server' error message, but I'm now getting the following error message.

QWidget: Cannot create a QWidget when no GUI is being used
Aborted

The only reason I'm using the QWidget class because I'm using qwtplot & QwtPlotCurve

caduel
1st September 2009, 20:28
Bad luck: you need a gui when you want to create widgets.
You might have to setup a "dummy" X server (not necessarily on the same machine your app is running on) and set DISPLAY to point to that machine.

You might be lucky (doubt it) and it might be possible to create a QImage without creating a QWidget. But I don't think qwt's api supports that.