From 151e8a166455dc52abe3a809fd81803973ca2154 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Tue, 6 Jul 2021 10:54:11 +0800 Subject: [PATCH] Minor tweaks Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- examples/mainwindow/main.cpp | 1 - examples/mainwindow/mainwindow.cpp | 3 +++ examples/quick/main.cpp | 1 - examples/widget/main.cpp | 1 - examples/widget/widget.cpp | 1 + examples/windows.manifest | 2 +- framelesswindowsmanager.cpp | 4 ++++ 7 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/mainwindow/main.cpp b/examples/mainwindow/main.cpp index 1e6981a..f07ba48 100644 --- a/examples/mainwindow/main.cpp +++ b/examples/mainwindow/main.cpp @@ -27,7 +27,6 @@ int main(int argc, char *argv[]) { - QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); // High DPI scaling is enabled by default from Qt 6 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) // Windows: we are using the manifest file to get maximum compatibility diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp index c2eeca3..8776c43 100644 --- a/examples/mainwindow/mainwindow.cpp +++ b/examples/mainwindow/mainwindow.cpp @@ -29,6 +29,9 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags) { + setAttribute(Qt::WA_DontCreateNativeAncestors); + createWinId(); + appMainWindow = new Ui::MainWindow; appMainWindow->setupUi(this); diff --git a/examples/quick/main.cpp b/examples/quick/main.cpp index feae057..244fa75 100644 --- a/examples/quick/main.cpp +++ b/examples/quick/main.cpp @@ -30,7 +30,6 @@ int main(int argc, char *argv[]) { - QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); // High DPI scaling is enabled by default from Qt 6 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) // Windows: we are using the manifest file to get maximum compatibility diff --git a/examples/widget/main.cpp b/examples/widget/main.cpp index 929ed11..b7f2455 100644 --- a/examples/widget/main.cpp +++ b/examples/widget/main.cpp @@ -27,7 +27,6 @@ int main(int argc, char *argv[]) { - QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); // High DPI scaling is enabled by default from Qt 6 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) // Windows: we are using the manifest file to get maximum compatibility diff --git a/examples/widget/widget.cpp b/examples/widget/widget.cpp index 10188d1..b643655 100644 --- a/examples/widget/widget.cpp +++ b/examples/widget/widget.cpp @@ -34,6 +34,7 @@ Widget::Widget(QWidget *parent) : QWidget(parent) { + setAttribute(Qt::WA_DontCreateNativeAncestors); createWinId(); setupUi(); startTimer(500); diff --git a/examples/windows.manifest b/examples/windows.manifest index f6318c9..7242841 100644 --- a/examples/windows.manifest +++ b/examples/windows.manifest @@ -1,6 +1,6 @@ - + diff --git a/framelesswindowsmanager.cpp b/framelesswindowsmanager.cpp index ce44dd5..d54bf4e 100644 --- a/framelesswindowsmanager.cpp +++ b/framelesswindowsmanager.cpp @@ -25,6 +25,7 @@ #include "framelesswindowsmanager.h" #include #include +#include #include #include "utilities.h" #ifdef FRAMELESSHELPER_USE_UNIX_VERSION @@ -44,6 +45,9 @@ void FramelessWindowsManager::addWindow(QWindow *window) if (!window) { return; } + if (!QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) { + QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); + } #ifdef FRAMELESSHELPER_USE_UNIX_VERSION framelessHelperUnix()->removeWindowFrame(window); #else