From 3dfca40680ada8bf3b10252f630d630e54cf55ea Mon Sep 17 00:00:00 2001
From: zhuzichu <zhuzichu520@gmail.com>
Date: Wed, 24 Jan 2024 15:41:10 +0800
Subject: [PATCH] fix bug #412

---
 src/FluFramelessHelper.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/FluFramelessHelper.cpp b/src/FluFramelessHelper.cpp
index 57a0d940..a390b264 100644
--- a/src/FluFramelessHelper.cpp
+++ b/src/FluFramelessHelper.cpp
@@ -241,10 +241,13 @@ bool FluFramelessHelper::eventFilter(QObject *obj, QEvent *ev){
 
 void FluFramelessHelper::componentComplete(){
     auto o = parent();
-    while (nullptr != o) {
-        window = (QQuickWindow*)o;
+    do {
+        window = qobject_cast<QQuickWindow *>(o);
+        if (window) {
+            break;
+        }
         o = o->parent();
-    }
+    } while (nullptr != o);
     if(!window.isNull()){
         _stayTop = QQmlProperty(window,"stayTop");
         _screen = QQmlProperty(window,"screen");