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.
在服务器远程运行会弹出窗口显示画面的代码时,可能遇到上述报错
首先执行`export QT_DEBUG_PLUGINS=1`,再运行一次导致报错的代码。可以看到详细错误信息,我这里看到具体错误为:
libxcb-icccm.so.4: cannot open shared
少了这样一个包,但是直接`apt-get update`,`apt-get install libxcb-icccm`是找不到的。此时应该执行`apt search libxcb-icccm`,得到如下结果
libxcb-icccm4/focal,now 0.4.1-1.1 amd64 utility libraries for X C Binding -- icccmlibxcb-icccm4-dev/focal 0.4.1-1.1 amd64 utility libraries for X C Binding -- icccm, development files
可以看到其实是包名弄错了,重新执行`apt install libxcb-icccm4`就可以了。
如上所述补上一堆包之后,最后运行一开始想要跑的代码,错误变成`qt.qpa.xcb: could not connect to display`,这个就是远程服务器无法显示弹窗的问题了,需要配置xming和xshell。xshell是一个terminal,其可以将服务器要展示的东西转发到xming所承接的本地端口上,这两个软件的下载链接和配置如下所示:
xming:Xming X Server for Windows download | SourceForge.net
xshell:Free for Home/School - Xshell and Xftp Free Licensing (netsarang.com)
配置教程:
1.XMing + XShell 打开Linux服务器网页界面_xshell打开网页-CSDN博客
2.Windows Xming +Xshell 实现远程 linux gui 界面本地展示_xming xshell-CSDN博客