在Fedora 10上编译。
我刚开始写我的第一个qt GUI应用程序。我使用了所有默认设置。
它只是一个简单的表格。它建立没有任何错误。但是当我尝试运行该应用程序时,我收到以下消息:
Starting /home/rob/projects/qt/test1/test1/test1...
No protocol specified
test1: cannot connect to X server :0.0
非常感谢任何建议。
一般的原因如下:
环境变量中没有设置DISPLAY。
解决方案:
export DISPLAY=:0.0
./myQtCmdHere
(这个似乎不是有问题的那个,因为它表明了它正在尝试连接到哪个X显示器。而且,它并不总是0.0,但大多数情况下是)
非授权用户尝试运行X应用程序
解决方案(作为拥有X权限的用户,即:您自己)
xhost +local:root # where root is the local user you want to grant access to.
同时,如果您希望您的X服务器能够接收TCP连接,则这些天您几乎总是需要显式启用此功能。要测试您的服务器是否允许远程TCP连接,请尝试:
telnet 127.0.0.1 6000
如果telnet能够连接,则您的X服务器正在侦听。如果不能连接,则任何远程X应用程序也无法连接,您需要在服务器上启用远程TCP连接。
check_install_xvfb() { # check and install xvfb
if hash xvfb-run 2>/dev/null; then
:
else
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install xvfb
fi
}
check_install_xvfb
export DISPLAY=localhost:1.0
xvfb-run -a bash .misc/tests.sh
# .misc/tests.sh is script that runs unit tests. You can replace it with something suitable to you.