📌 问题背景
在 Ubuntu 24.04(Wayland 环境)中通过在线安装器安装 Qt 6.10.2 后,启动 Qt Creator 时出现如下错误:
From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform 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:
xcb, eglfs, vnc, wayland-brcm, wayland-egl, wayland, linuxfb,
vkkhrdisplay, minimal, minimalegl, offscreen.
🔍 问题分析
从报错可以提取两个关键信息:
1️⃣ Qt 找到了 xcb 插件,但无法加载
Could not load the Qt platform plugin "xcb"
说明:
- 插件存在 ✔️
- 但依赖库缺失 ❌
2️⃣ Qt 6.5+ 新增依赖提示(关键)
From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed...
👉 这是核心原因!
从 Qt 6.5 开始:
xcb插件新增依赖:libxcb-cursor0- 如果系统未安装,会直接导致 Qt 应用(包括 Qt Creator)启动失败
⚠️ 为什么在 Wayland 环境也会报这个错?
即使系统是 Wayland:
- Qt 默认仍然优先尝试加载 xcb(X11)插件
- 或在初始化阶段检查其依赖
- 如果依赖缺失 → 直接崩溃
👉 所以这不是 Wayland 配置问题,而是系统库缺失问题
✅ 解决方案
只需安装缺失依赖:
bash
sudo apt install libxcb-cursor0
🚀 验证结果
安装完成后:
bash
qtcreator
👉 Qt Creator 可以正常启动 ✅
💡 补充建议
为了避免类似问题,建议在 Ubuntu 上安装 Qt 后补齐常见依赖:
bash
sudo apt install \
libxcb-cursor0 \
libxcb-xinerama0 \
libxkbcommon-x11-0
🧾 总结
| 问题 | 原因 | 解决 |
|---|---|---|
| Qt Creator 无法启动 | Qt 6.5+ 新增依赖缺失 | 安装 libxcb-cursor0 |
| 报错 xcb 插件加载失败 | 系统库不完整 | 补齐 xcb 相关库 |
📎 一句话总结
👉 Qt 6.5+ 在 Linux 上新增了 xcb 依赖(libxcb-cursor0),Ubuntu 默认未安装,需手动补齐,否则 Qt Creator 无法启动。
✍️ 后记
这个问题非常容易误导:
- 表面看是 Wayland / Qt 配置问题 ❌
- 实际是系统依赖缺失 ✔️
属于典型的 "插件在,但依赖不在" 场景。
如果你也在做 Qt6 + Linux 部署,这类问题基本绕不开,建议提前整理依赖清单 👍