设置环境变量 export QT_DEBUG_PLUGINS=1
加了这个环境变量,让我看到了QT程序加载的过程,看到了详细的报错信息。
所以各位可以多试试几个参数值,比如从:0.0开始,一直试。
但是这样设置,每个项目都要这样整,干脆在树莓派上,设置一个全局变量:
sudo vim /etc/profile
添加:
export DISPLAY=:0.0,注意这个值是要试出来的
按esc键,然后:wq退出保存
刷新:
source /etc/profile
安装Qt5.15.0后,在运行测试用例时弹出错误:
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
Aborted (core dumped)
------------------------------------------------
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
已放弃
根据问题描述,虽然能够找到但是不能加载Qt平台插件“xcb”,虽然接下来又说重新安装可能能够解决,这个可能的话,还是尽量作为最下的选择吧。
定位问题
修改配置文件~/.bashrc:
vim ~/.bashrc
在最末尾添加如下语句,会在qtcreator启动时,列出详细的错误提示。
export QT_DEBUG_PLUGINS=1
保存退出编辑,使配置文件生效:
source ~/.bashrc
运行ldd libqxcb.so,查看关联内容:
ldd libqxcb.so
echo $DISPLAY
如果echo $DISPLAY返回空
在vi /etc/profile内添加export DISPLAY=:0.0
执行source /etc/profile
第二步:然后ssh终端安装xorg并使用xclock测试能否回传图像:
apt-get install xorg
xclock