From d47c839e57c0bbeed060f4dfc0ffceb8f90a3ace Mon Sep 17 00:00:00 2001 From: ice Date: Fri, 17 Jul 2026 23:05:01 +0800 Subject: [PATCH] fix(example): preserve the custom title bar on Linux KDE Breeze calls QMainWindow::menuBar() while polishing a QMainWindow. This replaces the custom menu widget with an empty QMenuBar and schedules WindowBar for deletion. Use the built-in Fusion style on Linux to avoid the Breeze code path while preserving native styles on other platforms. --- examples/mainwindow/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/mainwindow/main.cpp b/examples/mainwindow/main.cpp index 7052bbb..4979ef9 100644 --- a/examples/mainwindow/main.cpp +++ b/examples/mainwindow/main.cpp @@ -27,6 +27,14 @@ int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); QApplication a(argc, argv); +#ifdef Q_OS_LINUX + // KDE Breeze calls QMainWindow::menuBar() while polishing the window. When a custom title bar + // is installed through QMainWindow::setMenuWidget(), that call replaces it with an empty + // QMenuBar and schedules the custom widget for deletion. Use Fusion on Linux so the WindowBar + // remains installed and visible without changing the native styles on other platforms. + QApplication::setStyle(QStringLiteral("Fusion")); +#endif + MainWindow w; w.show();