无法使用Qt应用程序连接到X服务器:0.0

问题描述:

在Fedora 10上编译.

Compiling on Fedora 10.

我刚刚启动了我的第一个qt GUI应用程序.我使用了所有默认设置.

I have just started my first qt GUI application. I used all the default settings.

它只是一个简单的形式.它构建良好,没有任何错误.但是当我尝试运行该应用程序时.我收到以下消息:

Its just a simple form. It builds OK without any errors. But when I try and run the application. I get the following message:

Starting /home/rob/projects/qt/test1/test1/test1...
No protocol specified
test1: cannot connect to X server :0.0

谢谢您的建议,

造成这种情况的一般原因如下:

The general causes for this are as follows:

  1. 未在环境中设置DISPLAY.
    解决方案:

  1. DISPLAY not set in the environment.
    Solution:

export DISPLAY=:0.0
./myQtCmdHere

(虽然这似乎不是错误的,因为它说X试图连接到它.而且,它并不总是0.0,但大多数时候是)

( This one doesn't appear to be the one at fault though, as its saying which X display its trying to connect to. Also, its not always 0.0, but most of the time it is )

非授权用户试图运行X应用程序
解决方案(作为X拥有用户,即:您自己)

Non-Authorised User trying to run the X Application
Solution ( as X owning user, ie: yourself )

xhost +local:root   # where root is the local user you want to grant access to.