diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index 8656ca6c09..2d8ddc1fa4 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -717,7 +717,14 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
 
     const TransformType tt = transformType(painter->deviceTransform(), aditionalDevicePixelRatio);
 
-    bool canDrawDirectly = false;
+    bool canDrawDirectly = false;    
+    if (themeData.widget)
+        qDebug() << __FUNCTION__ << themeData << themeData.widget
+                 << "natpar=" << themeData.widget->nativeParentWidget()
+                 << "translucentToplevel=" << translucentToplevel
+                 << "painter->opacity=" << painter->opacity()
+                 << "devtype=" << painter->paintEngine()->paintDevice()->devType();
+
     if (themeData.widget && painter->opacity() == 1.0 && !themeData.rotate
         && tt != ComplexTransform && !themeData.mirrorVertically
         && !translucentToplevel) {
@@ -725,17 +732,21 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
         const QPaintDevice *enginePaintDevice = painter->paintEngine()->paintDevice();
         switch (enginePaintDevice->devType()) {
         case QInternal::Widget:
+            qDebug() << "canDrawDirectly = true: QInternal::Widget";
             canDrawDirectly = true;
             break;
         case QInternal::Image:
             // Ensure the backing store has received as resize and is initialized.
             if (QBackingStore *bs = backingStoreForWidget(themeData.widget))
-                if (bs->size().isValid() && bs->paintDevice() == enginePaintDevice)
+                if (bs->size().isValid() && bs->paintDevice() == enginePaintDevice) {
                     canDrawDirectly = true;
+                    qDebug() << "canDrawDirectly = true BS";
+                }
         }
     }
-
+//    canDrawDirectly = false;
     const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0);
+qDebug() << __FUNCTION__ << themeData.partId << "dc="     << dc;
     const bool result = dc
         ? drawBackgroundDirectly(dc, themeData, aditionalDevicePixelRatio)
         : drawBackgroundThruNativeBuffer(themeData, aditionalDevicePixelRatio);
@@ -769,6 +780,7 @@ static QRegion scaleRegion(const QRegion &region, qreal factor)
 */
 bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, qreal additionalDevicePixelRatio)
 {
+    qDebug() << __FUNCTION__ << dc << themeData;
     QPainter *painter = themeData.painter;
 
     const QPointF redirectionDelta(painter->deviceMatrix().dx(), painter->deviceMatrix().dy());
@@ -817,6 +829,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa
 bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeData,
                                                             qreal additionalDevicePixelRatio)
 {
+    qDebug() << __FUNCTION__ << themeData;
     QPainter *painter = themeData.painter;
     QRectF rectF = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio);
 
@@ -2708,6 +2721,8 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
                     // Draw handle
                     theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT;
                     theme.stateId = stateId;
+                    qDebug() << __FUNCTION__ << "SBP_THUMBBTNHOR=" << SBP_THUMBBTNHORZ
+                             << "SBP_THUMBBTNVERT=" << SBP_THUMBBTNVERT;
                     d->drawBackground(theme);
 
                     const QRect gripperBounds = QWindowsXPStylePrivate::scrollBarGripperBounds(flags, widget, &theme);
@@ -3957,6 +3972,40 @@ QWindowsXPStyle::QWindowsXPStyle(QWindowsXPStylePrivate &dd) : QWindowsStyle(dd)
 {
 }
 
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const XPThemeData &t)
+{
+    QDebugStateSaver saver(d);
+    d.nospace();
+    d << "XPThemeData(" << t.widget << ", theme=#" << t.theme << ", " << t.htheme
+        << ", partId=" << t.partId << ", stateId=" << t.stateId << ", rect=" << t.rect
+        << ", mirrorHorizontally=" << t.mirrorHorizontally << ", mirrorVertically="
+        << t.mirrorVertically << ", noBorder=" << t.noBorder << ", noContent=" << t.noContent
+        << ", rotate=" << t.rotate << ')';
+    return d;
+}
+
+QDebug operator<<(QDebug d, const ThemeMapKey &k)
+{
+    QDebugStateSaver saver(d);
+    d.nospace();
+    d << "ThemeMapKey(theme=#" << k.theme
+        << ", partId=" << k.partId << ", stateId=" << k.stateId
+        << ", noBorder=" << k.noBorder << ", noContent=" << k.noContent << ')';
+    return d;
+}
+
+QDebug operator<<(QDebug d, const ThemeMapData &td)
+{
+    QDebugStateSaver saver(d);
+    d.nospace();
+    d << "ThemeMapData(alphaType=" << td.alphaType
+      << ", dataValid=" << td.dataValid << ", partIsTransparent=" << td.partIsTransparent
+      << ", hasAlphaChannel=" << td.hasAlphaChannel << ", wasAlphaSwapped=" << td.wasAlphaSwapped
+      << ", hadInvalidAlpha=" << td.hadInvalidAlpha << ')';
+    return d;
+}
+#endif // QT_NO_DEBUG_STREAM
 
 // Debugging code ---------------------------------------------------------------------[ START ]---
 // The code for this point on is not compiled by default, but only used as assisting
diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h
index fb5210cb07..92941f33fa 100644
--- a/src/widgets/styles/qwindowsxpstyle_p_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p_p.h
@@ -64,6 +64,8 @@
 
 QT_BEGIN_NAMESPACE
 
+class QDebug;
+
 // TMT_TEXTSHADOWCOLOR is wrongly defined in mingw
 #if TMT_TEXTSHADOWCOLOR != 3818
 #undef TMT_TEXTSHADOWCOLOR
@@ -183,6 +185,12 @@ struct ThemeMapData {
                      hasAlphaChannel(false), wasAlphaSwapped(false), hadInvalidAlpha(false) {}
 };
 
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const XPThemeData &t);
+QDebug operator<<(QDebug d, const ThemeMapKey &k);
+QDebug operator<<(QDebug d, const ThemeMapData &td);
+#endif
+
 class QWindowsXPStylePrivate : public QWindowsStylePrivate
 {
     Q_DECLARE_PUBLIC(QWindowsXPStyle)
