https://bugs.kde.org/show_bug.cgi?id=484405
Anatoly <liyiy26...@felibg.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |liyiy26...@felibg.com --- Comment #4 from Anatoly <liyiy26...@felibg.com> --- This issue affects Telegram Desktop and qBittorrent: when disabling tray icon in settings app instantly closes. And when the icon is disabled its impossible to use file dialogs: app abruptly closes when selecting any file or closing file dialog. Below there is my MRE. Without setQuitOnLastWindowClosed(false) line all woks fine. But when you uncomment it and try to open file dialog (with disabled icon) app closes. But if you start with setQuitOnLastWindowClosed(false) and trayIcon->show() enabled the dialog works fine. main.cpp: ``` #include <QApplication> #include <QMessageBox> #include "Window.hpp" int main(int argc, char *argv[]) { const auto app = QApplication(argc, argv); /* QApplication::setQuitOnLastWindowClosed(false); */ Window window; window.show(); return app.exec(); } ``` Window.hpp: ``` #pragma once #include <QApplication> #include <QCheckBox> #include <QDialog> #include <QFileDialog> #include <QPushButton> #include <QStyle> #include <QSystemTrayIcon> #include <QVBoxLayout> class Window : public QDialog { Q_OBJECT QCheckBox *showIconCheckBox; QSystemTrayIcon *trayIcon; QPushButton *button; public: Window() { showIconCheckBox = new QCheckBox("Show icon"); button = new QPushButton("Show dialog"); connect(button, &QAbstractButton::clicked, this, [] { const auto fname = QFileDialog::getOpenFileName(); qInfo() << fname; }); const auto mainLayout = new QVBoxLayout; mainLayout->addWidget(showIconCheckBox); mainLayout->addWidget(button); setLayout(mainLayout); trayIcon = new QSystemTrayIcon(this); trayIcon->setIcon( QApplication::style()->standardIcon(QStyle::SP_TabCloseButton)); /* trayIcon->show(); */ showIconCheckBox->setChecked(trayIcon->isVisible()); connect(showIconCheckBox, &QAbstractButton::toggled, trayIcon, &QSystemTrayIcon::setVisible); } }; ``` meson.build: ``` project( 'test-tray-icon', 'cpp', default_options: ['cpp_std=c++20']) qt6_mod = import('qt6') qt6_dep = dependency('qt6', modules: ['Core','Gui', 'Widgets']) processed = qt6_mod.preprocess( moc_headers : 'Window.hpp', ) executable('a', ['main.cpp', processed], dependencies: qt6_dep) ``` Alternative CMakeLists.txt: ``` cmake_minimum_required(VERSION 3.16) project(test-tray-icon LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) qt_standard_project_setup() qt_add_executable(a main.cpp Window.hpp) target_link_libraries(a PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets) ``` -- You are receiving this mail because: You are watching all bug changes.