Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. qt.qpa.xcb: QXcbConnection: XCB error: on Raspberry Pi 3B

qt.qpa.xcb: QXcbConnection: XCB error: on Raspberry Pi 3B

Scheduled Pinned Locked Moved Unsolved Qt for Python
18 Posts 3 Posters 11.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    California
    wrote on last edited by
    #1

    Hello, I did install last release of Raspbian OS on RPi-3B for my python project with QT5 GUI and an error occurs when app run. after that, everything works normally. With previous release of Raspbian OS no such errors happend. Searching over net gave me some results, but nothing helped in my case. What can I do to make sure no errors would occur again?
    Here is small example of code to demonstrade the situation:

    main.py

    
    import gui
    import sys
    import datetime
    import time
    
    
    
    from PyQt5 import QtCore, QtGui, QtWidgets
    from PyQt5.QtWidgets import QWidget, QApplication
    from PyQt5.QtCore import QTimer
    from PyQt5.QtGui import QPixmap
    
    logIN_ON = False
    
    #=============================================================================
    #-----------------------------------------------------------------------------
    def add_image():
        qpixmap = QPixmap('/home/pi/Project/python_logo.png')
        master.label_login.setPixmap(qpixmap)
    #-----------------------------------------------------------------------------
    def loging_in():
        global logIN_ON
        user_name = "asd"
        password = "123"
        
        u_n = master.lineEdit_user_name.text()
        p_w = master.lineEdit_password.text()
    
        if ((user_name == u_n) and (password == p_w)):
            logIN_ON = True
            add_image()
        else:
            logIN_ON = False
    #=============================================================================
    
    def time_show():
        now = datetime.datetime.now()
        master.Time.setText(now.strftime("%H" + ":" + "%M" + ":" + "%S"))
    
    def prozenje():
        time_show()
        master.pushButton_Log_in.clicked.connect(loging_in)
    
    
    if __name__ == "__main__":
        app = QtWidgets.QApplication(sys.argv)
        gui_master = gui.QtWidgets.QWidget()
        master = gui.Ui_Form()
        master.setupUi(gui_master)         
        timer = QTimer()
        timer.timeout.connect(prozenje)
        timer.start(1000)
        gui_master.show()
        sys.exit(app.exec_())
    
    

    gui.py

    # -*- coding: utf-8 -*-
    
    # Form implementation generated from reading ui file 'gui.ui'
    #
    # Created by: PyQt5 UI code generator 5.15.2
    #
    # WARNING: Any manual changes made to this file will be lost when pyuic5 is
    # run again.  Do not edit this file unless you know what you are doing.
    
    
    from PyQt5 import QtCore, QtGui, QtWidgets
    
    
    class Ui_Form(object):
        def setupUi(self, Form):
            Form.setObjectName("Form")
            Form.resize(445, 239)
            self.Time = QtWidgets.QLineEdit(Form)
            self.Time.setGeometry(QtCore.QRect(100, 30, 113, 30))
            self.Time.setObjectName("Time")
            self.pushButton_Log_in = QtWidgets.QPushButton(Form)
            self.pushButton_Log_in.setGeometry(QtCore.QRect(100, 170, 111, 30))
            self.pushButton_Log_in.setObjectName("pushButton_Log_in")
            self.lineEdit_user_name = QtWidgets.QLineEdit(Form)
            self.lineEdit_user_name.setGeometry(QtCore.QRect(100, 90, 113, 30))
            self.lineEdit_user_name.setObjectName("lineEdit_user_name")
            self.lineEdit_password = QtWidgets.QLineEdit(Form)
            self.lineEdit_password.setGeometry(QtCore.QRect(100, 130, 113, 30))
            self.lineEdit_password.setObjectName("lineEdit_password")
            self.label_login = QtWidgets.QLabel(Form)
            self.label_login.setGeometry(QtCore.QRect(250, 30, 151, 171))
            self.label_login.setText("")
            self.label_login.setObjectName("label_login")
            self.label = QtWidgets.QLabel(Form)
            self.label.setGeometry(QtCore.QRect(20, 90, 81, 22))
            self.label.setObjectName("label")
            self.label_2 = QtWidgets.QLabel(Form)
            self.label_2.setGeometry(QtCore.QRect(20, 130, 68, 22))
            self.label_2.setObjectName("label_2")
            self.label_3 = QtWidgets.QLabel(Form)
            self.label_3.setGeometry(QtCore.QRect(20, 30, 51, 22))
            self.label_3.setObjectName("label_3")
    
            self.retranslateUi(Form)
            QtCore.QMetaObject.connectSlotsByName(Form)
    
        def retranslateUi(self, Form):
            _translate = QtCore.QCoreApplication.translate
            Form.setWindowTitle(_translate("Form", "Form"))
            self.pushButton_Log_in.setText(_translate("Form", "Log IN"))
            self.label.setText(_translate("Form", "Username"))
            self.label_2.setText(_translate("Form", "Password"))
            self.label_3.setText(_translate("Form", "Time"))
    
    

    An error message:

    qt.qpa.xcb: QXcbConnection: XCB error: 148 (Unknown), sequence: 191, resource id: 0, major code: 140 (Unknown), minor code: 20
    

    Regards, Vlado

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you install everything from the package manager ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        California
        wrote on last edited by
        #3

        Thanks for respond. Everything was installed on fresh copy of Raspberry Pi OS by commands below

        sudo apt-get install qt5-default
        sudo apt-get install python3-pyqt5 
        sudo apt-get install pyqt5-dev-tools
        

        then Project folder is copyed to:

        /home/vlado/Project
        

        in Project folder we call main.py to execute an app ...

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Do you have the same issue if you just show a simple widget ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 1 Reply Last reply
          0
          • C Offline
            C Offline
            California
            wrote on last edited by
            #5

            Yes, on the begining of this post is posted small example of python code for login in, which perfectly demonstrate the problem.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What I meant is to run something that is really minimal just to ensure it's not something in your code that might do strange stuff.

              Your code sample contains free functions that access an object created under the __main__ which is not the cleanest of design.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • C Offline
                C Offline
                California
                wrote on last edited by
                #7

                Ok, I will put together a simple example with only QT5 involved...

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  California
                  wrote on last edited by
                  #8

                  Here we are, I had SD card with fresh Raspbian OS installed (desctop version).
                  Only QT5 (version 5.15.2) installed with commands posted above and smallest possible code example.

                  app.py

                  import sys
                  from PyQt5.QtWidgets import QApplication, QWidget
                  if __name__ == "__main__":
                      app = QApplication(sys.argv)
                      w = QWidget()
                      w.resize(300,300)
                      w.setWindowTitle("QT5 example")
                      w.show()
                      sys.exit(app.exec_())
                  

                  Warning messages (2):

                  libEGL warning: DRI2: failed to authenticate
                  qt.qpa.xcb: QXcbConnection: XCB error: 148 (Unknown), sequence: 191, resource id: 0, major code: 140 (Unknown), minor code: 20
                  
                  1 Reply Last reply
                  0
                  • hskoglundH Offline
                    hskoglundH Offline
                    hskoglund
                    wrote on last edited by
                    #9

                    Hi, just tried your example on my Raspberry Pi 4 and it works fine (I get a small blank window with the title "Qt5 example").

                    Don't know if it's relevant, but I'm still on Debian 10 (Buster) where the default distro Qt version is 5.11.3:

                    henry@tungware1:~ $ lsb_release -a
                    No LSB modules are available.
                    Distributor ID:	Raspbian
                    Description:	Raspbian GNU/Linux 10 (buster)
                    Release:	10
                    Codename:	buster
                    henry@tungware1:~ $ sudo apt-get install qt5-default
                    Reading package lists... Done
                    Building dependency tree       
                    Reading state information... Done
                    qt5-default is already the newest version (5.11.3+dfsg1-1+rpi1+deb10u4).
                    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
                    henry@tungware1:~ $ sudo apt-get install python3-pyqt5
                    Reading package lists... Done
                    Building dependency tree       
                    Reading state information... Done
                    python3-pyqt5 is already the newest version (5.11.3+dfsg-1+rpi1+b3).
                    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
                    

                    I connect to my Raspberry PU using an old Samsung 22" monitor with just one HDMI connector and 1920x1080 resolution.

                    1 Reply Last reply
                    1
                    • C Offline
                      C Offline
                      California
                      wrote on last edited by
                      #10

                      Well, you have an old release of Raspbian (10 Buster) and qt5 version 5.11.3 in my case Raspbian is the newest release 11 - Bullseye and qt5 version 5.15.2.

                      1 Reply Last reply
                      0
                      • hskoglundH Offline
                        hskoglundH Offline
                        hskoglund
                        wrote on last edited by
                        #11

                        Perhaps the video output differ, what monitor do you use and is it connected through HDMI?

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          California
                          wrote on last edited by
                          #12

                          I don't have any monitor connected to RPi, I am working over VNC ... and with buster OS and qt5-5.11.3 no warning messages were appeared...

                          1 Reply Last reply
                          0
                          • hskoglundH Offline
                            hskoglundH Offline
                            hskoglund
                            wrote on last edited by hskoglund
                            #13

                            I remember trying VNC but I could not get Youtube to work over it :-(
                            Does Youtube work for you?

                            1 Reply Last reply
                            0
                            • SGaistS SGaist

                              Do you have the same issue if you just show a simple widget ?

                              C Offline
                              C Offline
                              California
                              wrote on last edited by
                              #14

                              @SGaist said in qt.qpa.xcb: QXcbConnection: XCB error: on Raspberry Pi 3B:

                              Do you have the same issue if you just show a simple widget ?

                              Any news about this topic?

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                Can you give the full explanation of your work setup ?

                                You started with issues related to Xorg but now you wrote that you are connecting to your Pi through VNC.

                                How did you setup everything ?
                                Is it the exact same setup as with Debian 10 ?

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                1
                                • C Offline
                                  C Offline
                                  California
                                  wrote on last edited by
                                  #16

                                  Thanks for your collaboration. I usualy did installation over ssh and everything worked ok until last update of raspbian. I did follow sugestions of yours and start fresh installation without enabled ssh and vnc. This time I got only one warning message shown below:

                                  libEGL warning: DRI2: failed to authenticate
                                  

                                  Is this one solvable, couse everything else works ok now?
                                  Thanks for help,

                                  Vlado

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #17

                                    This RaspberryPI Stack Exchange thread might help.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    0
                                    • C Offline
                                      C Offline
                                      California
                                      wrote on last edited by
                                      #18

                                      Update to topic: it seems that warning message below happends on RPi3B, but not on RPi3B+

                                      qt.qpa.xcb: QXcbConnection: XCB error: 148 (Unknown), sequence: 191, resource id: 0, major code: 140 (Unknown), minor code: 20
                                      

                                      I just took SD card with my app from my hardware system where RPi3B is heart of it and I put it into my test RPi3B+ and I noticed no such a warning message appeared in terminal...so it's strange...

                                      For warning message:

                                      libEGL warning: DRI2: failed to authenticate
                                      

                                      I will do complete new SD software installation and result will be posted here...
                                      Regards, Vlado

                                      1 Reply Last reply
                                      0

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved