Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QComboBox selection makes computer crash
Forum Updated to NodeBB v4.3 + New Features

QComboBox selection makes computer crash

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 11 Posters 3.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.
  • I IgorRecioH

    Hi everyone,

    this is my first comment in this forum and I'm quite newbie in Qt C++.

    I am developing a personal desktop application for managing expenses at home.

    I am having some issues with all of my QComboBox in the app. Let's see if I can explain it correctly:

    • I click on my QComboBox --> Options appear
    • If I click outside the QComboBox to close it (don't mind where), application crashes and my Ubuntu user session closes (It does not restart computer but I need to re-enter my credentials)
    • If I click on any option it works fine and it also works fine if I don't click an option but I press Escape to close the QComboBox.

    Is this behaviour expected? Am I doing something wrong?

    You can check my code here: https://github.com/igorrecioh/home_expenses_dsktp/blob/main/mainwindow.cpp

    Thanks a lot in advance.

    Kind regards,

    Igor

    EDIT: I am using Ubuntu 22.04.1 LTS and application uses Qt6 6.4.2

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #2

    @IgorRecioH said in QComboBox selection makes computer crash:

    Is this behaviour expected? Am I doing something wrong?

    In principle, no. Probably, else there is a problem.

    Reduce your code till it either occurs in minimal example and/or run under a debugger and look at the stack trace etc. when it crashes.

    I 1 Reply Last reply
    0
    • JonBJ JonB

      @IgorRecioH said in QComboBox selection makes computer crash:

      Is this behaviour expected? Am I doing something wrong?

      In principle, no. Probably, else there is a problem.

      Reduce your code till it either occurs in minimal example and/or run under a debugger and look at the stack trace etc. when it crashes.

      I Offline
      I Offline
      IgorRecioH
      wrote on last edited by
      #3

      @JonB
      Thanks a lot for your quick response. I have tried running app and debug it but it crashes and I cannot see anything in the stacktrace, quite annoying...

      Anyway, I will try with a minimal example and check if it happens too, as you suggest.

      I will keep you updated.

      Regards,

      Igor

      JonBJ 1 Reply Last reply
      0
      • I IgorRecioH

        @JonB
        Thanks a lot for your quick response. I have tried running app and debug it but it crashes and I cannot see anything in the stacktrace, quite annoying...

        Anyway, I will try with a minimal example and check if it happens too, as you suggest.

        I will keep you updated.

        Regards,

        Igor

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #4

        @IgorRecioH
        Is the only combobox stuff you do the on_filterByCbx_currentIndexChanged()? What you are describing seems unexpected and not connected to anything in your application. Is that is what is being triggered when it crashes? Does a standalone combobox exhibit this problem? Else edit up/down from there.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          IgorRecioH
          wrote on last edited by
          #5

          @JonB

          Good, I have just created an empty new project with a unique combobox, and it is also happening the crash. I am starting to think that there is something wrong in my computer or setup. Check code below:

          mainwindow.h

          #ifndef MAINWINDOW_H
          #define MAINWINDOW_H
          
          #include <QMainWindow>
          
          QT_BEGIN_NAMESPACE
          namespace Ui { class MainWindow; }
          QT_END_NAMESPACE
          
          class MainWindow : public QMainWindow
          {
              Q_OBJECT
          
          public:
              MainWindow(QWidget *parent = nullptr);
              ~MainWindow();
          
          private:
              Ui::MainWindow *ui;
          };
          #endif // MAINWINDOW_H
          
          

          mainwindow.cpp

          #include "mainwindow.h"
          #include "ui_mainwindow.h"
          
          MainWindow::MainWindow(QWidget *parent)
              : QMainWindow(parent)
              , ui(new Ui::MainWindow)
          {
              ui->setupUi(this);
              ui->comboBox->addItem("kk");
          }
          
          MainWindow::~MainWindow()
          {
              delete ui;
          }
          

          main.cpp

          #include "mainwindow.h"
          
          #include <QApplication>
          
          int main(int argc, char *argv[])
          {
              QApplication a(argc, argv);
              MainWindow w;
              w.show();
              return a.exec();
          }
          

          mainwindow.ui

          <?xml version="1.0" encoding="UTF-8"?>
          <ui version="4.0">
           <class>MainWindow</class>
           <widget class="QMainWindow" name="MainWindow">
            <property name="geometry">
             <rect>
              <x>0</x>
              <y>0</y>
              <width>800</width>
              <height>600</height>
             </rect>
            </property>
            <property name="windowTitle">
             <string>MainWindow</string>
            </property>
            <widget class="QWidget" name="centralwidget">
             <widget class="QComboBox" name="comboBox">
              <property name="geometry">
               <rect>
                <x>140</x>
                <y>110</y>
                <width>86</width>
                <height>25</height>
               </rect>
              </property>
             </widget>
            </widget>
            <widget class="QMenuBar" name="menubar">
             <property name="geometry">
              <rect>
               <x>0</x>
               <y>0</y>
               <width>800</width>
               <height>22</height>
              </rect>
             </property>
            </widget>
            <widget class="QStatusBar" name="statusbar"/>
           </widget>
           <resources/>
           <connections/>
          </ui>
          

          CMakeLists.txt

          cmake_minimum_required(VERSION 3.5)
          
          project(test VERSION 0.1 LANGUAGES CXX)
          
          set(CMAKE_AUTOUIC ON)
          set(CMAKE_AUTOMOC ON)
          set(CMAKE_AUTORCC ON)
          
          set(CMAKE_CXX_STANDARD 17)
          set(CMAKE_CXX_STANDARD_REQUIRED ON)
          
          find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
          find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
          
          set(PROJECT_SOURCES
                  main.cpp
                  mainwindow.cpp
                  mainwindow.h
                  mainwindow.ui
          )
          
          if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
              qt_add_executable(test
                  MANUAL_FINALIZATION
                  ${PROJECT_SOURCES}
              )
          # Define target properties for Android with Qt 6 as:
          #    set_property(TARGET test APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
          #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
          # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
          else()
              if(ANDROID)
                  add_library(test SHARED
                      ${PROJECT_SOURCES}
                  )
          # Define properties for Android with Qt 5 after find_package() calls as:
          #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
              else()
                  add_executable(test
                      ${PROJECT_SOURCES}
                  )
              endif()
          endif()
          
          target_link_libraries(test PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
          
          set_target_properties(test PROPERTIES
              MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
              MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
              MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
              MACOSX_BUNDLE TRUE
              WIN32_EXECUTABLE TRUE
          )
          
          install(TARGETS test
              BUNDLE DESTINATION .
              LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
          
          if(QT_VERSION_MAJOR EQUAL 6)
              qt_finalize_executable(test)
          endif()
          
          
          1 Reply Last reply
          0
          • I Offline
            I Offline
            IgorRecioH
            wrote on last edited by
            #6

            @JonB

            @JonB said in QComboBox selection makes computer crash:

            @IgorRecioH
            Is the only combobox stuff you do the on_filterByCbx_currentIndexChanged()? What you are describing seems unexpected and not connected to anything in your application. Is that is what is being triggered when it crashes? Does a standalone combobox exhibit this problem? Else edit up/down from there.

            That combobox you mention is the only one which has currentIndexChanged signal. The value of the rest of comboboxes are read when clicking a button. Anyway, all of them exhibit this problem, yes.

            Quite crazy, must say. When I try one of the examples provided in QtDesigner, they work fine. It is true that this example do not have a .ui file, I mean, they create the objects directly in C++ code.

            1 Reply Last reply
            1
            • I Offline
              I Offline
              IgorRecioH
              wrote on last edited by
              #7

              Just as update: I have compiled my Qt app in a Windows10 VM and I cannot reproduce the problem and it's working fine. So maybe it is related to Ubuntu.

              Furthermore, exploring /var/log/syslog I found this line when crashing the app:

              Feb  9 21:17:27 igorrecio-XXX gnome-shell[53810]: GNOME Shell crashed with signal 11
              Feb  9 21:17:27 igorrecio-XXX gnome-shell[53810]: == Stack trace for context 0x56459ff96490 ==
              

              Searching on the internet, seems to be something related to GNOME, specifically in Ubuntu 22.04...

              JonBJ 1 Reply Last reply
              0
              • I IgorRecioH

                Just as update: I have compiled my Qt app in a Windows10 VM and I cannot reproduce the problem and it's working fine. So maybe it is related to Ubuntu.

                Furthermore, exploring /var/log/syslog I found this line when crashing the app:

                Feb  9 21:17:27 igorrecio-XXX gnome-shell[53810]: GNOME Shell crashed with signal 11
                Feb  9 21:17:27 igorrecio-XXX gnome-shell[53810]: == Stack trace for context 0x56459ff96490 ==
                

                Searching on the internet, seems to be something related to GNOME, specifically in Ubuntu 22.04...

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #8

                @IgorRecioH
                Since there was nothing in your code changing combobox behaviour it does sound right that any combobox will do it and it is some issue on your platform. But I (and others) use Ubuntu 22.04 with GNOME and have no trouble, though I am Qt5. It would be very serious if what you report happens to everyone, you are saying 22.04/GNOME/Qt6 cannot work with a combobox, I would have expected to hear about this! Maybe try a Qt other than 6.4.2?

                1 Reply Last reply
                2
                • S Offline
                  S Offline
                  SamuelAdesola
                  wrote on last edited by
                  #9

                  I am experiencing same problem now

                  1 Reply Last reply
                  1
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #10

                    I have also same problem using Qt6 6.4.2. I am waiting for a solution. I don't want to migrate Qt5 because of this problem.

                    JoeCFDJ 1 Reply Last reply
                    1
                    • ? A Former User

                      I have also same problem using Qt6 6.4.2. I am waiting for a solution. I don't want to migrate Qt5 because of this problem.

                      JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on last edited by
                      #11

                      @Dogukan-Arat I tested the /widgets/painting/basicdrawing example which has a few combo boxes and do not see any crash.
                      Qt 6.5.0 and LUbuntu 22.04

                      JonBJ 1 Reply Last reply
                      0
                      • JoeCFDJ JoeCFD

                        @Dogukan-Arat I tested the /widgets/painting/basicdrawing example which has a few combo boxes and do not see any crash.
                        Qt 6.5.0 and LUbuntu 22.04

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #12

                        @JoeCFD
                        I seem to remember some recent post on something "similar" to this may have stated that Lubuntu worked but Ubuntu did not?

                        JoeCFDJ 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @JoeCFD
                          I seem to remember some recent post on something "similar" to this may have stated that Lubuntu worked but Ubuntu did not?

                          JoeCFDJ Offline
                          JoeCFDJ Offline
                          JoeCFD
                          wrote on last edited by
                          #13

                          @JonB I will check it out later.

                          JoeCFDJ 1 Reply Last reply
                          0
                          • JoeCFDJ JoeCFD

                            @JonB I will check it out later.

                            JoeCFDJ Offline
                            JoeCFDJ Offline
                            JoeCFD
                            wrote on last edited by JoeCFD
                            #14

                            @JoeCFD Tried the same example on Qt 6.4.0 and Ubuntu 22.04. No crash.

                            1 Reply Last reply
                            1
                            • I Offline
                              I Offline
                              iPriyonto
                              wrote on last edited by
                              #15

                              I am having the same problem too. However, in my case, it crashes only when I have the combo box open, and I try to interact with other widgets I have on the window.

                              1 Reply Last reply
                              1
                              • M Offline
                                M Offline
                                Mriv31
                                wrote on last edited by
                                #16

                                Same problem.

                                Ubuntu 22.04 LTS - Wayland
                                PyQt6 6.5.0

                                1 Reply Last reply
                                0
                                • L Offline
                                  L Offline
                                  Li Kui
                                  wrote on last edited by
                                  #17

                                  同样的问题,VMware,Ubuntu-22.04.2,Qt6.5

                                  1 Reply Last reply
                                  0
                                  • BosGemilerB Offline
                                    BosGemilerB Offline
                                    BosGemiler
                                    wrote on last edited by
                                    #18

                                    I have same issue. When I clicked on combobox, I can see dropdown menu, and everything is fine so far. But when I click on any item in dropdown menu, there appears a crash and I find myself on log in page of ubuntu.

                                    It's not the only bug I faced in ubuntu. There are many others too. Unfortunately, I didn't see any good release of Ubuntu except Ubuntu 14 and 18.

                                    Goodbye Ubuntu, Welcome Debian !

                                    JoeCFDJ 1 Reply Last reply
                                    0
                                    • BosGemilerB BosGemiler

                                      I have same issue. When I clicked on combobox, I can see dropdown menu, and everything is fine so far. But when I click on any item in dropdown menu, there appears a crash and I find myself on log in page of ubuntu.

                                      It's not the only bug I faced in ubuntu. There are many others too. Unfortunately, I didn't see any good release of Ubuntu except Ubuntu 14 and 18.

                                      Goodbye Ubuntu, Welcome Debian !

                                      JoeCFDJ Offline
                                      JoeCFDJ Offline
                                      JoeCFD
                                      wrote on last edited by JoeCFD
                                      #19

                                      @BosGemiler It could be a wayland related issue. Switch to Xorg and try it again.
                                      On Login screen, there is a setting icon and click it to switch to Xorg. The default on Ubuntu now is Wayland.

                                      1 Reply Last reply
                                      1
                                      • D Offline
                                        D Offline
                                        default
                                        wrote on last edited by
                                        #20

                                        I faced the same issue while working with PyQt6 on Ubuntu 22.04

                                        So I ran the following minimal example:-

                                        from PyQt6.QtWidgets import (
                                          QApplication,
                                          QWidget,
                                          QComboBox,
                                        )
                                        
                                        import sys
                                        
                                        
                                        class Window(QWidget):
                                          def __init__(self):
                                            super().__init__()
                                        
                                            combobox = QComboBox(self)
                                            combobox.addItems(['option 1', 'option 2', 'option 3'])
                                        
                                            self.setGeometry(0,0,500,500)
                                            self.setWindowTitle('Combobox Bug')
                                            self.show()
                                        
                                        
                                        if __name__ == '__main__':
                                          app = QApplication([])
                                          window = Window()
                                          sys.exit(app.exec())
                                        

                                        Wayland : It crashes and I am sent to login screen where I have to login again.
                                        Xorg: No crash

                                        Same thing happens on PySide6.

                                        JoeCFDJ 1 Reply Last reply
                                        0
                                        • D default

                                          I faced the same issue while working with PyQt6 on Ubuntu 22.04

                                          So I ran the following minimal example:-

                                          from PyQt6.QtWidgets import (
                                            QApplication,
                                            QWidget,
                                            QComboBox,
                                          )
                                          
                                          import sys
                                          
                                          
                                          class Window(QWidget):
                                            def __init__(self):
                                              super().__init__()
                                          
                                              combobox = QComboBox(self)
                                              combobox.addItems(['option 1', 'option 2', 'option 3'])
                                          
                                              self.setGeometry(0,0,500,500)
                                              self.setWindowTitle('Combobox Bug')
                                              self.show()
                                          
                                          
                                          if __name__ == '__main__':
                                            app = QApplication([])
                                            window = Window()
                                            sys.exit(app.exec())
                                          

                                          Wayland : It crashes and I am sent to login screen where I have to login again.
                                          Xorg: No crash

                                          Same thing happens on PySide6.

                                          JoeCFDJ Offline
                                          JoeCFDJ Offline
                                          JoeCFD
                                          wrote on last edited by JoeCFD
                                          #21

                                          @default run
                                          strace yourapp
                                          to check if any plugin is missing. You may be able to get some hints about the reasons.

                                          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