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

问题描述 投票:0回答:1

当我安装

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/

但这并没有帮助。

qt qt-creator qt6 ubuntu-22.04
1个回答
1
投票

要解决此问题,我在运行部分“构建环境”中添加 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.

我知道我需要安装 libxcb-cursor

sudo apt-get install libxcb-cursor0

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

© www.soinside.com 2019 - 2024. All rights reserved.