From a55e873c48f05eb935e51a787850bf1b9406e227 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Sun, 16 Apr 2023 20:00:51 +0800 Subject: [PATCH] fix: window resizing not working under Qt 6 This is a workaround solution for QTBUG-112356. See the following discussion for details. Thanks @yyc12345 from GitHub for finding the cause of the issue. Related: https://github.com/BLumia/pineapple-pictures/pull/81 --- app/framelesswindow.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/framelesswindow.cpp b/app/framelesswindow.cpp index 679c6c9..6149670 100644 --- a/app/framelesswindow.cpp +++ b/app/framelesswindow.cpp @@ -15,13 +15,17 @@ FramelessWindow::FramelessWindow(QWidget *parent) : QWidget(parent) , m_centralLayout(new QVBoxLayout(this)) { - // TODO: Remove the comment below when we switch to Qt 6 completely. +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // The Qt::WindowMinMaxButtonsHint or Qt::WindowMinimizeButtonHint here is to + // provide the ability to use Winkey + Up/Down to toggle minimize/maximize. + // But a bug introduced in Qt6 that this flag will break the WM_NCHITTEST event. + // See: QTBUG-112356 and discussion in https://github.com/BLumia/pineapple-pictures/pull/81 + // Thanks @yyc12345 for finding out the source of the issue. + this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint); +#else // There is a bug in Qt 5 that will make pressing Meta+Up cause the app // fullscreen under Windows, see QTBUG-91226 to learn more. // The bug seems no longer exists in Qt 6 (I only tested it under Qt 6.3.0). -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint); -#else this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint); #endif // QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)