diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index e737fe1d8d..869cb7c255 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -426,7 +426,6 @@ void qt_init(QApplicationPrivate *priv, int type) Q_UNUSED(priv); Q_UNUSED(type); - qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); QColormap::initialize(); if (const QPalette *toolTipPalette = QGuiApplicationPrivate::platformTheme()->palette(QPlatformTheme::ToolTipPalette)) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 355ef5bee0..2fbedb4809 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5116,6 +5116,10 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP QPaintEvent e(toBePainted); QCoreApplication::sendSpontaneousEvent(q, &e); + // Native widgets need to be marked dirty on screen so painting will be done in correct context + if (backingStore && !onScreen && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow())) + backingStore->markDirtyOnScreen(toBePainted, q, offset); + //restore if (paintEngine) { #ifdef Q_WS_MAC diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 262165a024..9d444fee8f 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -146,10 +146,12 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO setWindowModified_helper(); setWinId(win->winId()); -// first check children. and create them if necessary -// q_createNativeChildrenAndSetParent(q->windowHandle(),q); + // Check children and create windows for them if necessary + q_createNativeChildrenAndSetParent(q->windowHandle(), q); -// qDebug() << "create_sys" << q << q->internalWinId(); + // If widget is already shown, set window visible, too + if (q->isVisible()) + win->setVisible(true); } void QWidget::destroy(bool destroyWindow, bool destroySubWindows) diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index 5ddb596b4f..a12770799d 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -46,6 +46,7 @@ #ifndef QT_NO_ACCESSIBILITY #include #endif +#include QT_BEGIN_NAMESPACE @@ -458,8 +459,14 @@ void QWidgetWindow::handleExposeEvent(QExposeEvent *event) { if (isExposed()) { m_widget->setAttribute(Qt::WA_Mapped); - if (!event->region().isNull()) + if (!event->region().isNull()) { + // Exposed native widgets need to be marked dirty to get them repainted correctly. + if (m_widget->internalWinId() && !m_widget->isWindow()) { + if (QWidgetBackingStore *bs = m_widget->d_func()->maybeBackingStore()) + bs->markDirty(event->region(), m_widget); + } m_widget->d_func()->syncBackingStore(event->region()); + } } else { m_widget->setAttribute(Qt::WA_Mapped, false); }