QComboBox selection makes computer crash
-
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
-
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
@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.
-
@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.
@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
-
@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
@IgorRecioH
Is the only combobox stuff you do theon_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. -
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()
-
@JonB said in QComboBox selection makes computer crash:
@IgorRecioH
Is the only combobox stuff you do theon_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.
-
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...
-
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...
@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? -
I am experiencing same problem now
-
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.
-
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.
-
@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 -
@JoeCFD
I seem to remember some recent post on something "similar" to this may have stated that Lubuntu worked but Ubuntu did not? -
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 !
-
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 !
@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. -
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 crashSame thing happens on PySide6.