Qxcbconnection: Could Not Connect to Display Aborted, When Installing Qt on Linux

NS-3 - NetAnim error: qt.qpa.xcb: could not connect to display localhost:0.0

Got it solved!
What I did is:

  1. Enabled Virtualization in BIOS.
  2. Reset the WSL.
  3. Upgraded WSL1 to WSL2.
  4. Set WSL: 2 as default, <deb_pack>: 2 default.

Using WSL2 doesn't really make fuss with Qt.

Qt: launch a message box periodically with crontab in ubuntu

I think the DISPLAY environment is missing. I suggest you wrap your application in a wrapper script (let's call it horloge.sh):

#!/bin/sh
DISPLAY=:0
export DISPLAY
/home/salwa/computing/cpp/horloge

Then put the horloge.sh in your crontab. Don't forget to do a chmod u+x horloge.sh so that the script is executable.

QXcbConnection: Could not connect to display, when remotely debugging program with Qt5

When you deploy your application and run it from within the X11 system on device itself, you're finding it works because here it has access to the DISPLAY environment variable which (briefly put) tells it where to display itself. This environment variable has been set further up the process tree in your X session.

When you launch a program via the debugger, Qt Creator is connecting to the remote device (via your settings in Tools > Options > Devices), and running the program via ssh. In this context your program no longer knows where to display itself, as obviously it can't display in ssh. It faults on the line you indicated because this is where the XCB subsystem is trying to determine which X-Server to connect to for this purpose.

So to answer your question: you need to manually provide the DISPLAY environment variable when remote debugging.

An easy way to test this is to go to Projects Mode, find the kit you are using to build for the remote device, and select the Run settings. Under this, you should find an Run Environment section. Here you can add a new variable called DISPLAY and set its value to the identifier of the display you are running on (I'm guessing you'll want :0.0, indicating the first available screen on localhost, although you should read about the DISPLAY variable e.g. here or here).

A longer-term, potentially better solution would be to set the same variable in the settings of your Kit (Tools > Options > Build & Run > Kits > Environment). This will then apply for future programs you create using this.



Related Topics



Leave a reply



Submit