QXcbConnection: Could not connect to display

  • Hi,

    I am trying to run my Qt program (named ROBOCRT) in ubuntu 14.04 through 'init.d' script. The program runs fine if I launch it from terminal. However, when I launch it through the 'init.d' script using 'sudo service ROBOCRT start', I get the following error message 'QXcbConnection: Could not connect to display' in a log file. I am working with Qt 5.3. Any hint how to resolve this problem.

    Kind regards

  • Welcome to the Qt Dev Net!

    Do you use widgets in your app?
    If so then you will not be able to run your app without X11 and X11 is not started yet when the services are starting.

    What are trying to achieve ?

  • Thx.

    At the moment I am running the app after user login, not during system bootup. The app runs without error in the terminal.

    The app is based on 'Qt Widgets App', however, I disbaled the window display by commenting out 'w.show();' line in 'main.cpp'.

  • If you are using QApplication or QGuiApplication in the main() then your app will try to initialize graphics subsystem anyway.
    But without X11 it is not possible.

    You need to create a Qt Console application.

  • The problem is solved by the Console App. Thx.

  • @chjatala can you please ellaborate your answer?thx

Log in to reply