error: QXcbConnection: Could not connect to display

/*********************************************************************************
 *           error: QXcbConnection: Could not connect to display
 * 说明:
 *     调试Qt5支持XCB平台模式的时候遇到的错误。
 *
 *                                              2017-11-28 深圳 南山平山村 曾剑锋
 ********************************************************************************/
    
一、参考文档:
    1. Qt5: QXcbConnection: Could not connect to display Aborted (core dumped)
        http://bbs.csdn.net/topics/391894181

二、Qt支持X11 XCB

     /home/zengjf/zengjf/zengjfos/buildroot-2017.02.3/.config - Buildroot 2017.02.3 C
    o> Target packages > Graphic libraries and applications (graphic/text) > Qt5 ──
      ┌────────────────────────────────── Qt5 ──────────────────────────────────┐
      │  Arrow keys navigate the menu.  <Enter> selects submenus ---> (or empty │  
      │  submenus ----).  Highlighted letters are hotkeys.  Pressing <Y>        │  
      │  selectes a feature, while <N> will exclude a feature.  Press           │  
      │  <Esc><Esc> to exit, <?> for Help, </> for Search.  Legend: [*] feature │  
      │ ┌────^(-)─────────────────────────────────────────────────────────────┐ │  
      │ │    -*-     gui module                                               │ │  
      │ │    -*-       widgets module                                         │ │  
      │ │              *** OpenGL support needs an OpenGL-capable backend *** │ │  
      │ │    [*]       linuxfb support                                        │ │  
      │ │              *** directfb backend available if directfb is enabled *│ │  
      │ │    [*]       X.org XCB support                                      │ │  
      │ │              *** eglfs backend available if OpenGL and EGL are enabl│ │  
      │ │    (xcb)        Default graphical platform                             │ │  
      │ │    [ ]       fontconfig support                                     │ │  
      │ │    [ ]       GIF support                                            │ │  
      │ └────┴(+)─────────────────────────────────────────────────────────────┘ │  
      ├─────────────────────────────────────────────────────────────────────────┤  
      │        <Select>    < Exit >    < Help >    < Save >    < Load >         │  
      └─────────────────────────────────────────────────────────────────────────┘  

三、错误解决方法
    1. Error 1
        1. cmd: ./Helloworld -platform xcb
        2. error: QXcbConnection: Could not connect to display
        3. resolution: export DISPLAY=:0.0

    2. Error 2
        1. cmd: ./Helloworld -platform xcb
        2. error: QXcbConnection: Could not connect to display :0.0
        3. resolution: 检查X11 Server正常运行

 

点赞