Ubuntu 22.04 & Qt 6.5:qt.qpa.plugin 无法加载“”中的 Qt 平台插件“xcb”,即使已找到

Par*_*H.R 4 qt qt-creator qt6 ubuntu-22.04

当我安装Ubuntu 22.04和 时Qt 6.5.2,我遇到了一个错误,该错误导致我的任何项目无法运行,并且它没有按预期显示输出。

qt.qpa.plugin:即使找到了“”,也无法加载Qt平台插件“xcb”。该应用程序无法启动,因为无法初始化 Qt 平台插件。重新安装应用程序可能会解决此问题。

可用的平台插件有:vnc、minimal、wayland-egl、offscreen、xcb、vkkhrdisplay、eglfs、minimalegl、linuxfb、wayland。

在此输入图像描述

我检查了/home/username/Qt/6.5.2/gcc_64/plugins/platforms/路径并了解到所有文件都是正确的。

在此输入图像描述

我也尝试:

export QT_QPA_PLATFORM_PLUGIN_PATH=/home/username/Qt/6.5.2/gcc_64/plugins/platforms/
Run Code Online (Sandbox Code Playgroud)

但这没有帮助。

Par*_*H.R 11

要解决此问题,我在运行部分“构建环境”中添加 QT_DEBUG_PLUGINS = 1

在此输入图像描述

这有助于我记录并查看实际发生的情况。

由此

qt.core.plugin.factoryloader: checking directory path "/home/parisa/build-untitled1-Desktop_Qt_6_5_2_GCC_64bit-Debug/platforms" ...
qt.core.library: "/home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so" cannot load: Cannot load library /home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so: (libxcb-cursor.so.0: cannot open shared object file: No such file or directory)
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so" : "Cannot load library /home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so: (libxcb-cursor.so.0: cannot open shared object file: No such file or directory)"
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.
Run Code Online (Sandbox Code Playgroud)

我知道我需要安装 libxcb-cursor

sudo apt-get install libxcb-cursor0
Run Code Online (Sandbox Code Playgroud)

请注意,这种情况只发生在 Qt 6.5 以上,我之前没有这个问题。

  • 感谢这个解释,还有如何调试日志的详细信息。 (2认同)