解决MobaXterm通过SSH启动远程Qt图形应用失败

背景

通过MobaXterm X11-forwarding 功能可以将远程图形应用投射到本地进行展示(因为MobaXterm本身内建X Server,可以直接执行远程端的X窗口程序,无需任何配置),如图1所示:
在这里插入图片描述
图1 MobaXterm支持remote display forwaded through ssh

现象

运行图形化程序,报错如下:

QFactoryLoader::QFactoryLoader() checking directory path "/home/hzwangjb/nertc/sdk/demo/linux/qt_demo/dem                                            o/ci/Linux-NERtc-Demo/x86_64/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/home/hzwangjb/nertc/sdk/demo/linux/qt_demo/demo/ci/Linux-NE                                            Rtc-Demo/x86_64/plugins/platforms/libqxcb.so"
Found metadata in lib /home/hzwangjb/nertc/sdk/demo/linux/qt_demo/demo/ci/Linux-NERtc-Demo/x86_64/plugins                                            /platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "archreq": 0,
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 330752
}


Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/hzwangjb/nertc/sdk/demo/linux/qt_demo/dem                                            o/ci/Linux-NERtc-Demo/x86_64/platforms" ...
loaded library "/home/hzwangjb/nertc/sdk/demo/linux/qt_demo/demo/ci/Linux-NERtc-Demo/x86_64/plugins/platf                                            orms/libqxcb.so"
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 app                                            lication may fix this problem.

可以通知设置环境变量QT_DEBUG_PLUGINS=1打开调试开关,能看到更详细的信息

关键错误信息如下:

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 app                                            lication may fix this problem.

排查下来Qt应用打包了libqxcb.so, 也找到了,网上google一圈也未能解决问题,重心放在了xcb问题上,直接原因是qt.qpa.xcb: could not connect to display, 没有设置DISPLAY环境变量。

解决办法

根因是笔者是通过控制台ssh指令进行登录的,导致MobaXterm没有正确配置DISPLAY,正确操作应该使用Session新建一个SSH终端,如下:

在这里插入图片描述

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
Got keys from plugin meta data ("ibus") QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforminputcontexts" ... loaded library "/home/rvbust/.local/lib/python3.10/site-packages/PyQt5/Qt5/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so" QFactoryLoader::QFactoryLoader() checking directory path "/home/rvbust/.local/lib/python3.10/site-packages/PyQt5/Qt5/plugins/styles" ... QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/styles" ... Traceback (most recent call last): File "/home/rvbust/Documents/FlexLocation_new/ViewerApp.py", line 30, in <module> main() File "/home/rvbust/Documents/FlexLocation_new/ViewerApp.py", line 24, in main main_window = GlyphViewerApp() File "/home/rvbust/Documents/FlexLocation_new/ViewerApp.py", line 10, in __init__ self.setup() File "/home/rvbust/Documents/FlexLocation_new/ViewerApp.py", line 15, in setup self.ui.setupUi(self) File "/home/rvbust/Documents/FlexLocation_new/glyph_view.py", line 33, in setupUi self.actionLoadCloud = QAction(MainWindow) TypeError: 'PySide6.QtGui.QAction.__init__' called with wrong argument types: PySide6.QtGui.QAction.__init__(GlyphViewerApp) Supported signatures: PySide6.QtGui.QAction.__init__(Union[PySide6.QtGui.QIcon, PySide6.QtGui.QPixmap], str, Optional[PySide6.QtCore.QObject] = None) PySide6.QtGui.QAction.__init__(Optional[PySide6.QtCore.QObject] = None) PySide6.QtGui.QAction.__init__(str, Optional[PySide6.QtCore.QObject] = None) QLibraryPrivate::unload succeeded on "/home/rvbust/.local/lib/python3.10/site-packages/PyQt5/Qt5/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so" QLibraryPrivate::unload succeeded on "/home/rvbust/.local/lib/python3.10/site-packages/PyQt5/Qt5/plugins/platformthemes/libqgtk3.so" QLibraryPrivate::unload succeeded on "/home/rvbust/.local/lib/python3.10/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" QLibraryPrivate::unload succeeded on "Xcursor" (faked)
06-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值