diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 63539c0103..e835c7fb4f 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1953,6 +1953,8 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
         // QtBUG-25831, used to suppress delivery in qwidgetwindow.cpp
         setMouseEventFlags(&ev, ev.flags() | Qt::MouseEventCreatedDoubleClick);
     }
+    if (ev.type() != QEvent::MouseMove)
+        qDebug() << __FUNCTION__ << "window=" << window;
 
     QGuiApplication::sendSpontaneousEvent(window, &ev);
     e->eventAccepted = ev.isAccepted();
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 5b5c1bd0e3..739ad97eb8 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1003,6 +1003,7 @@ QIcon QWindow::icon() const
 void QWindow::raise()
 {
     Q_D(QWindow);
+    qDebug() << __FUNCTION__ << this;
 
     d->updateSiblingPosition(QWindowPrivate::PositionTop);
 
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 3f417fde27..6ea1b05d8d 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -643,12 +643,13 @@ QWindowsWindowData
     const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle));
     QWindowsContext::instance()->setWindowCreationContext(context);
 
-    qCDebug(lcQpaWindows).nospace()
+    qDebug().nospace()
         << "CreateWindowEx: " << w << " class=" << windowClassName << " title=" << title
         << '\n' << *this << "\nrequested: " << rect << ": "
         << context->frameWidth << 'x' <<  context->frameHeight
         << '+' << context->frameX << '+' << context->frameY
-        << " custom margins: " << context->customMargins;
+        << " custom margins: " << context->customMargins
+        << "top" << w->flags().testFlag(Qt::WindowStaysOnTopHint);
 
     result.hwnd = CreateWindowEx(exStyle, classNameUtf16, titleUtf16,
                                  style,
@@ -701,6 +702,7 @@ void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChang
     if (topLevel) {
         swpFlags |= SWP_NOACTIVATE;
         if ((flags & Qt::WindowStaysOnTopHint) || (type == Qt::ToolTip)) {
+            qDebug() << __FUNCTION__ << w;
             SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, swpFlags);
             if (flags & Qt::WindowStaysOnBottomHint)
                 qWarning("QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time");
@@ -1803,6 +1805,7 @@ void QWindowsWindow::setWindowFlags(Qt::WindowFlags flags)
 QWindowsWindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt,
                                                               unsigned flags) const
 {
+    qDebug() << __FUNCTION__ << window() << wt.testFlag(Qt::WindowStaysOnTopHint);
     WindowCreationData creationData;
     creationData.fromWindow(window(), wt, flags);
     creationData.applyWindowFlags(m_data.hwnd);
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index b8ec5774b0..2232edeed1 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -6518,6 +6518,7 @@ bool QWidget::hasFocus() const
 
 void QWidget::setFocus(Qt::FocusReason reason)
 {
+    qDebug() << __FUNCTION__ << this << reason;
     if (!isEnabled())
         return;
 
@@ -11790,6 +11791,8 @@ void QWidget::updateMicroFocus()
 void QWidget::raise()
 {
     Q_D(QWidget);
+    qDebug() << __FUNCTION__ << this << "isWindow=" << isWindow()
+             << "WA_WState_Created=" << testAttribute(Qt::WA_WState_Created);
     if (!isWindow()) {
         QWidget *p = parentWidget();
         const int parentChildCount = p->d_func()->children.size();
@@ -11802,8 +11805,10 @@ void QWidget::raise()
             p->d_func()->children.move(from, parentChildCount - 1);
         if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
             create();
-        else if (from == parentChildCount - 1)
+        else if (from == parentChildCount - 1) {
+            qDebug() << __FUNCTION__ << "return from == parentChildCount - 1";
             return;
+        }
 
         QRegion region(rect());
         d->subtractOpaqueSiblings(region);
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index d30154410c..83b27015bf 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -625,6 +625,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
 
     QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(),
                                                                qt_button_down, widget);
+    if (event->type() != QEvent::MouseMove)
+        qDebug() << __FUNCTION__ << this << "receiver=" << receiver;
 
     if (!receiver) {
         if (event->type() == QEvent::MouseButtonRelease)
diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp
index e509f522d8..cf4db78764 100644
--- a/src/widgets/kernel/qwindowcontainer.cpp
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -410,6 +410,7 @@ void QWindowContainer::parentWasMoved(QWidget *parent)
 
 void QWindowContainer::parentWasRaised(QWidget *parent)
 {
+    qDebug() << __FUNCTION__ << "parent=" << parent;
     if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)) {
         if (d->window->parent())
             d->window->raise();
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index 418764223d..ac00de176d 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -1248,10 +1248,12 @@ void QMdiAreaPrivate::internalRaise(QMdiSubWindow *mdiChild) const
             if (!child || !childWindows.contains(child))
                 continue;
             if (!child->isHidden() && windowStaysOnTop(child)) {
-                if (stackUnderChild)
+                if (stackUnderChild) {
                     child->stackUnder(stackUnderChild);
-                else
+                } else {
+                    qDebug() << __FUNCTION__ << "raising top child " << child;
                     child->raise();
+                }
                 stackUnderChild = child;
             }
         }
