Index: /trunk/src/gui/kernel/qapplication_pm.cpp
===================================================================
--- /trunk/src/gui/kernel/qapplication_pm.cpp	(revision 604)
+++ /trunk/src/gui/kernel/qapplication_pm.cpp	(revision 605)
@@ -451,4 +451,20 @@
 }
 
+/*!
+    Returns a QWidget pointer or 0 if there is no widget corresponding to the
+    given HWND. As opposed to QWidget::find(), correctly handles WC_FRAME
+    windows created for top level widgets.
+ */
+QWidget *qt_widget_from_hwnd(HWND hwnd)
+{
+    char buf[10];
+    if (WinQueryClassName(hwnd, sizeof(buf), buf)) {
+        if (!strcmp(buf, "#1")) // WC_FRAME
+            hwnd = WinWindowFromID(hwnd, FID_CLIENT);
+        return QWidget::find(hwnd);
+    }
+    return 0;
+}
+
 // application no-grab option
 bool qt_nograb()
@@ -700,5 +716,5 @@
         return 0;
 
-    QWidget *w = qWidgetFromHWND(hwnd);
+    QWidget *w = qt_widget_from_hwnd(hwnd);
     return w ? w->window() : 0;
 }
@@ -796,9 +812,6 @@
 
 #if defined(QT_DEBUGMSGFLOW)
-        {
-            QDbgStr str = qStrQMSG(qmsg);
-            if (!str.isEmpty())
-                qDebug() << "*** [W]" << str;
-        }
+        if (qmsg.msg != WM_QUERYICON)
+            qDebug() << "*** [W]" << qmsg;
 #endif
 
@@ -1269,9 +1282,6 @@
 
 #if defined(QT_DEBUGMSGFLOW)
-        {
-            QDbgStr str = qStrQMSG(qmsg);
-            if (!str.isEmpty())
-                qDebug() << "*** [F]" << str;
-        }
+        if (qmsg.msg != WM_QUERYICON)
+            qDebug() << "*** [F]" << qmsg;
 #endif
 
@@ -1368,9 +1378,6 @@
 
 #if defined(QT_DEBUGMSGFLOW)
-        {
-            QDbgStr str = qStrQMSG(qmsg);
-            if (!str.isEmpty())
-                qDebug() << "*** [FC]" << str;
-        }
+        if (qmsg.msg != WM_QUERYICON)
+            qDebug() << "*** [FC]" << qmsg;
 #endif
 
@@ -1538,5 +1545,5 @@
             setAutoCapture(popup->d_func()->frameWinId()); // grab mouse/keyboard
         }
-        if (!qWidgetFromHWND(WinQueryActiveWindow(HWND_DESKTOP))) {
+        if (!qt_widget_from_hwnd(WinQueryActiveWindow(HWND_DESKTOP))) {
             // the popup is opened while another application is active. Steal
             // the focus (to receive keyboard input and to make sure we get
@@ -2267,5 +2274,5 @@
 
 #if defined(QT_DEBUGMSGFLOW)
-    qDebug() << " PAINT BEGIN:" << rcl << "hps:" << qStrHPS(d_func()->hd);
+    qDebug() << "PAINT BEGIN:" << rcl << "hps" << qDebugFmtHex(d_func()->hd);
 #endif
 
@@ -2287,5 +2294,5 @@
     updRect.translate(data->wrect.topLeft());
 #if defined(QT_DEBUGMSGFLOW)
-    qDebug() << " PAINT updRect:" << updRect;
+    qDebug() << "PAINT updRect:" << updRect;
 #endif
 
@@ -2297,5 +2304,5 @@
 
 #if defined(QT_DEBUGMSGFLOW)
-    qDebug() << " PAINT END";
+    qDebug() << "PAINT END";
 #endif
 
@@ -2552,40 +2559,19 @@
  *****************************************************************************/
 
-/*!
-    Returns a QWidget pointer or 0 if there is no widget corresponding to the
-    given HWND. As opposed to QWidget::find(), correctly handles WC_FRAME
-    windows created for top level widgets. Used for debugging.
- */
-QWidget *qWidgetFromHWND(HWND hwnd)
-{
-    char buf[10];
-    if (WinQueryClassName(hwnd, sizeof(buf), buf)) {
-        if (!strcmp(buf, "#1")) // WC_FRAME
-            hwnd = WinWindowFromID(hwnd, FID_CLIENT);
-        return QWidget::find(hwnd);
-    }
-    return 0;
-}
-
-/*!
-    \internal
-
-    Returns a human readable widget name in the form "class/name". Used for
-    debugging.
- */
-QDbgStr qWidgetName(QWidget *w)
-{
-    if (w)
-        return QString()
-            .sprintf("%s.%s", w->metaObject()->className(),
-                     w->objectName().isEmpty() ? "<noname>" :
-                     w->objectName().toUtf8().constData());
-    return QString(QLatin1String("<no-widget>"));
-}
-
-typedef QLatin1String QCStr;
+QDebug operator<<(QDebug debug, const QDebugHWND &d)
+{
+    debug << qDebugFmtHex(d.hwnd) << qt_widget_from_hwnd(d.hwnd);
+    return debug;
+}
+
+QDebug operator<<(QDebug debug, const RECTL &rcl)
+{
+    debug.nospace() << "RECTL(" << rcl.xLeft << "," << rcl.yBottom
+                    << " " << rcl.xRight << "," << rcl.yTop << ")";
+    return debug.space();
+}
 
 #define myDefFlagEx(var,fl,varstr,flstr) if (var & fl) { \
-    if (!varstr.isEmpty()) varstr += QCStr("|"); varstr += QCStr(flstr); \
+    if (!varstr.isEmpty()) varstr += "|"; varstr += flstr; \
 } else do {} while(0)
 
@@ -2593,182 +2579,7 @@
 #define myDefFlagCut(var,fl,varstr,pos) myDefFlagEx(var,fl,varstr,#fl + pos)
 
-QDbgStr qStrHWND(HWND hwnd)
-{
-    return QString().sprintf("%08lX/", hwnd) +
-           qWidgetName(qWidgetFromHWND(hwnd));
-}
-
-QDbgStr qStrHPS(HPS hps)
-{
-    return QString().sprintf("%08lX", hps);
-}
-
-QDbgStr qStrHPOINTER(HPOINTER hptr)
-{
-    return QString().sprintf("%08lX", hptr);
-}
-
-QDbgStr qStrHRGN(HRGN hrgn)
-{
-    return QString().sprintf("%08lX", hrgn);
-}
-
-QDbgStr qStrQMSG(const QMSG &qmsg)
-{
-    QString str;
-
-    #define myCaseBegin(a) case a: { \
-        str = QString().sprintf(#a ": hwnd %08lX.", qmsg.hwnd); \
-        str += qWidgetName(qWidgetFromHWND(qmsg.hwnd));
-    #define myCaseEnd() }
-
-    switch (qmsg.msg) {
-
-    myCaseBegin(WM_CHAR)
-        USHORT fl = SHORT1FROMMP(qmsg.mp1);
-        UCHAR repeat = CHAR3FROMMP(qmsg.mp1);
-        UCHAR scan = CHAR4FROMMP(qmsg.mp1);
-        USHORT ch = SHORT1FROMMP(qmsg.mp2);
-        USHORT vk = SHORT2FROMMP(qmsg.mp2);
-        str += QString().
-            sprintf(" rep %02d scan %02X ch %04X (%s) vk %04X",
-                    repeat, scan, ch, (ch > 32 && ch < 254) ?
-                    qPrintable(QString::fromLocal8Bit((char *)&ch, 1)) :
-                    qPrintable(QString(QChar(QLatin1Char(' ')))), vk);
-        QString flstr;
-        myDefFlagEx(fl, KC_CHAR, flstr, "CHAR");
-        myDefFlagEx(fl, KC_VIRTUALKEY, flstr, "VIRT");
-        myDefFlagEx(fl, KC_SCANCODE, flstr, "SCAN");
-        myDefFlagEx(fl, KC_SHIFT, flstr, "SHIFT");
-        myDefFlagEx(fl, KC_CTRL, flstr, "CTRL");
-        myDefFlagEx(fl, KC_ALT, flstr, "ALT");
-        myDefFlagEx(fl, KC_KEYUP, flstr, "UP");
-        myDefFlagEx(fl, KC_PREVDOWN, flstr, "PREVDWN");
-        myDefFlagEx(fl, KC_LONEKEY, flstr, "LONE");
-        myDefFlagEx(fl, KC_DEADKEY, flstr, "DEAD");
-        myDefFlagEx(fl, KC_COMPOSITE, flstr, "COMP");
-        myDefFlagEx(fl, KC_INVALIDCOMP, flstr, "INVCMP");
-        myDefFlagEx(fl, KC_TOGGLE, flstr, "TGGL");
-        myDefFlagEx(fl, KC_INVALIDCHAR, flstr, "INVCHR");
-        str += QString().sprintf(" KC(%04X,", fl) + flstr + QCStr(")");
-        break;
-    myCaseEnd()
-
-    myCaseBegin(WM_KBDLAYERCHANGED)
-        str += QString().sprintf(" mp1 %p mp2 %p", qmsg.mp1, qmsg.mp2);
-        break;
-    myCaseEnd()
-
-    myCaseBegin(WM_PAINT)
-        break;
-    myCaseEnd()
-
-    myCaseBegin(WM_SIZE)
-        str += QString().
-            sprintf(" old (%hd,%hd) new (%hd,%hd)",
-                    SHORT1FROMMP(qmsg.mp1), SHORT2FROMMP(qmsg.mp1),
-                    SHORT1FROMMP(qmsg.mp2), SHORT2FROMMP(qmsg.mp2));
-        SWP swp;
-        WinQueryWindowPos(qmsg.hwnd, &swp);
-        str += QCStr(" ") + qStrSWP(swp);
-        HWND p = WinQueryWindow(qmsg.hwnd, QW_PARENT);
-        if (p != NULLHANDLE && p != WinQueryDesktopWindow(0, 0)) {
-            WinQueryWindowPos(p, &swp);
-            str += QCStr(" p ") + qStrSWP(swp);
-        }
-        break;
-    myCaseEnd()
-
-    myCaseBegin(WM_MOVE)
-        SWP swp;
-        WinQueryWindowPos(qmsg.hwnd, &swp);
-        str += QCStr(" ") + qStrSWP(swp);
-        HWND p = WinQueryWindow(qmsg.hwnd, QW_PARENT);
-        if (p != NULLHANDLE && p != WinQueryDesktopWindow(0, 0)) {
-            WinQueryWindowPos(p, &swp);
-            str += QCStr(" p ") + qStrSWP(swp);
-        }
-        break;
-    myCaseEnd()
-
-    myCaseBegin(WM_WINDOWPOSCHANGED)
-        str += QCStr(" ") + qStrSWP(*((PSWP) qmsg.mp1));
-        ULONG awp = LONGFROMMP(qmsg.mp2);
-        QString awpstr;
-        myDefFlagEx(awp, AWP_MINIMIZED, awpstr, "MIN");
-        myDefFlagEx(awp, AWP_MAXIMIZED, awpstr, "MAX");
-        myDefFlagEx(awp, AWP_RESTORED, awpstr, "REST");
-        myDefFlagEx(awp, AWP_ACTIVATE, awpstr, "ACT");
-        myDefFlagEx(awp, AWP_DEACTIVATE, awpstr, "DEACT");
-        str += QCStr(" AWP(") + awpstr + QCStr(")");
-        break;
-    myCaseEnd()
-
-    myCaseBegin(WM_MINMAXFRAME)
-        str += QCStr(" ") + qStrSWP(*((PSWP) qmsg.mp1));
-        break;
-    myCaseEnd()
-
-    myCaseBegin(WM_ACTIVATE)
-        bool active = SHORT1FROMMP(qmsg.mp1);
-        HWND hwnd = (HWND)qmsg.mp2;
-        str += QCStr(" Active(") + QCStr(active ? "TRUE) " : "FALSE)");
-        str += QString().sprintf(" hwndActive %08lX.", hwnd);
-        str += qWidgetName(qWidgetFromHWND(hwnd));
-        break;
-    myCaseEnd()
-
-    myCaseBegin(WM_SETFOCUS)
-        HWND hwnd = (HWND)qmsg.mp1;
-        bool focus = SHORT1FROMMP(qmsg.mp2);
-        str += QCStr(" Focus(") + QCStr(focus ? "TRUE) " : "FALSE)");
-        str += QString().sprintf(" hwndFocus %08lX.", hwnd);
-        str += qWidgetName(qWidgetFromHWND(hwnd));
-        break;
-    myCaseEnd()
-
-    myCaseBegin(WM_FOCUSCHANGE)
-        HWND hwnd = (HWND)qmsg.mp1;
-        bool focus = SHORT1FROMMP(qmsg.mp2);
-        bool fl = SHORT2FROMMP(qmsg.mp2);
-        QString flstr;
-        myDefFlagEx(fl, FC_NOSETFOCUS, flstr, "NOSETFCS");
-        myDefFlagEx(fl, FC_NOLOSEFOCUS, flstr, "NOLOSEFCS");
-        myDefFlagEx(fl, FC_NOSETACTIVE, flstr, "NOSETACT");
-        myDefFlagEx(fl, FC_NOLOSEACTIVE, flstr, "NOLOSEACT");
-        myDefFlagEx(fl, FC_NOSETSELECTION, flstr, "NOSETSEL");
-        myDefFlagEx(fl, FC_NOLOSESELECTION, flstr, "NOSETSEL");
-        str += QCStr(" Focus(") + QCStr(focus ? "TRUE) " : "FALSE)");
-        str += QString().sprintf(" hwndFocus %08lX.", hwnd);
-        str += qWidgetName(qWidgetFromHWND(hwnd));
-        str += QCStr(" FC(") + flstr + QCStr(")");
-        break;
-    myCaseEnd()
-
-    default:
-#if 0
-        if (qmsg.msg == WM_QUERYICON)
-            break;
-        str = QString().sprintf("WM_%04lX: hwnd %08lX.", qmsg.msg, qmsg.hwnd);
-        str += qWidgetName(qWidgetFromHWND(qmsg.hwnd));
-#endif
-        break;
-    }
-
-    return str;
-
-    #undef myCaseEnd
-    #undef myCaseBegin
-}
-
-QDbgStr qStrRECTL(const RECTL &rcl)
-{
-    return QString().sprintf("RECTL(%ld,%ld %ld,%ld)",
-                             rcl.xLeft, rcl.yBottom, rcl.xRight, rcl.yTop);
-}
-
-QDbgStr qStrSWP(const SWP &swp)
-{
-    QString fl;
+QDebug operator<<(QDebug debug, const SWP &swp)
+{
+    QByteArray fl;
     myDefFlagEx(swp.fl, SWP_SIZE, fl, "SIZE");
     myDefFlagEx(swp.fl, SWP_MOVE, fl, "MOVE");
@@ -2788,7 +2599,152 @@
     myDefFlagEx(swp.fl, SWP_NOAUTOCLOSE, fl, "NOACLOSE");
 
-    return QString().sprintf("SWP(%ld,%ld %ldx%ld %08lX ",
-                             swp.x, swp.y, swp.cx, swp.cy, swp.hwndInsertBehind) +
-        fl + QLatin1String(")");
+    debug.nospace() << "SWP(" << swp.x << "," << swp.y
+                    << " " << swp.cx << "x" << swp.cy << " "
+                    << qDebugFmtHex(swp.hwndInsertBehind)
+                    << fl.constData() << ")";
+    return debug.space();
+}
+
+QDebug operator<<(QDebug debug, const QMSG &qmsg)
+{
+    #define myCaseBegin(a) case a: { \
+        debug << #a": hwnd" << qDebugHWND(qmsg.hwnd);
+    #define myCaseEnd() }
+
+    switch (qmsg.msg) {
+
+    myCaseBegin(WM_CHAR)
+        USHORT fl = SHORT1FROMMP(qmsg.mp1);
+        UCHAR repeat = CHAR3FROMMP(qmsg.mp1);
+        UCHAR scan = CHAR4FROMMP(qmsg.mp1);
+        USHORT ch = SHORT1FROMMP(qmsg.mp2);
+        USHORT vk = SHORT2FROMMP(qmsg.mp2);
+        QByteArray flstr;
+        myDefFlagEx(fl, KC_CHAR, flstr, "CHAR");
+        myDefFlagEx(fl, KC_VIRTUALKEY, flstr, "VIRT");
+        myDefFlagEx(fl, KC_SCANCODE, flstr, "SCAN");
+        myDefFlagEx(fl, KC_SHIFT, flstr, "SHIFT");
+        myDefFlagEx(fl, KC_CTRL, flstr, "CTRL");
+        myDefFlagEx(fl, KC_ALT, flstr, "ALT");
+        myDefFlagEx(fl, KC_KEYUP, flstr, "UP");
+        myDefFlagEx(fl, KC_PREVDOWN, flstr, "PREVDWN");
+        myDefFlagEx(fl, KC_LONEKEY, flstr, "LONE");
+        myDefFlagEx(fl, KC_DEADKEY, flstr, "DEAD");
+        myDefFlagEx(fl, KC_COMPOSITE, flstr, "COMP");
+        myDefFlagEx(fl, KC_INVALIDCOMP, flstr, "INVCMP");
+        myDefFlagEx(fl, KC_TOGGLE, flstr, "TGGL");
+        myDefFlagEx(fl, KC_INVALIDCHAR, flstr, "INVCHR");
+
+        debug << "rep" << qDebugFmt("%02d", repeat)
+              << "scan" << qDebugFmtHex(scan) << "ch" << qDebugFmtHex(ch)
+              << ((ch > 32 && ch < 254) ? QString::fromLocal8Bit((char *)&ch, 1) :
+                                          QString(QLatin1String(" ")))
+              << "vk" << qDebugFmtHex(vk);
+        debug.nospace() << "KC(" << qDebugFmtHex(fl) << ","
+                        << flstr.constData() << ")";
+        debug.space();
+        break;
+    myCaseEnd()
+
+    myCaseBegin(WM_KBDLAYERCHANGED)
+        debug << "mp1" << qmsg.mp1 << "mp2" << qmsg.mp2;
+        break;
+    myCaseEnd()
+
+    myCaseBegin(WM_PAINT)
+        debug << "mp1" << qmsg.mp1 << "mp2" << qmsg.mp2;
+        break;
+    myCaseEnd()
+
+    myCaseBegin(WM_SIZE)
+        SWP swp;
+        WinQueryWindowPos(qmsg.hwnd, &swp);
+        debug << "old " << SHORT1FROMMP(qmsg.mp1) << SHORT2FROMMP(qmsg.mp1)
+              << "new " << SHORT1FROMMP(qmsg.mp2) << SHORT2FROMMP(qmsg.mp2)
+              << swp;
+        HWND p = WinQueryWindow(qmsg.hwnd, QW_PARENT);
+        if (p != NULLHANDLE && p != WinQueryDesktopWindow(0, 0)) {
+            WinQueryWindowPos(p, &swp);
+            debug << "parent" << swp;
+        }
+        break;
+    myCaseEnd()
+
+    myCaseBegin(WM_MOVE)
+        SWP swp;
+        WinQueryWindowPos(qmsg.hwnd, &swp);
+        debug << swp;
+        HWND p = WinQueryWindow(qmsg.hwnd, QW_PARENT);
+        if (p != NULLHANDLE && p != WinQueryDesktopWindow(0, 0)) {
+            WinQueryWindowPos(p, &swp);
+            debug << "parent" << swp;
+        }
+        break;
+    myCaseEnd()
+
+    myCaseBegin(WM_WINDOWPOSCHANGED)
+        debug << *((PSWP) qmsg.mp1);
+        ULONG awp = LONGFROMMP(qmsg.mp2);
+        QByteArray awpstr;
+        myDefFlagEx(awp, AWP_MINIMIZED, awpstr, "MIN");
+        myDefFlagEx(awp, AWP_MAXIMIZED, awpstr, "MAX");
+        myDefFlagEx(awp, AWP_RESTORED, awpstr, "REST");
+        myDefFlagEx(awp, AWP_ACTIVATE, awpstr, "ACT");
+        myDefFlagEx(awp, AWP_DEACTIVATE, awpstr, "DEACT");
+        debug.nospace() << "AWP(" << awpstr.constData() << ")";
+        debug.space();
+        break;
+    myCaseEnd()
+
+    myCaseBegin(WM_MINMAXFRAME)
+        debug << *((PSWP) qmsg.mp1);
+        break;
+    myCaseEnd()
+
+    myCaseBegin(WM_ACTIVATE)
+        bool active = SHORT1FROMMP(qmsg.mp1);
+        HWND hwnd = (HWND)qmsg.mp2;
+        debug.nospace() << "Active(" << (active ? "TRUE)" : "FALSE)");
+        debug.space() << "hwndActive" << qDebugHWND(hwnd);
+        break;
+    myCaseEnd()
+
+    myCaseBegin(WM_SETFOCUS)
+        HWND hwnd = (HWND)qmsg.mp1;
+        bool focus = SHORT1FROMMP(qmsg.mp2);
+        debug.nospace() << "Focus(" << (focus ? "TRUE) " : "FALSE)");
+        debug.space() << "hwndFocus" << qDebugHWND(hwnd);
+        break;
+    myCaseEnd()
+
+    myCaseBegin(WM_FOCUSCHANGE)
+        HWND hwnd = (HWND)qmsg.mp1;
+        bool focus = SHORT1FROMMP(qmsg.mp2);
+        bool fl = SHORT2FROMMP(qmsg.mp2);
+        QByteArray flstr;
+        myDefFlagEx(fl, FC_NOSETFOCUS, flstr, "NOSETFCS");
+        myDefFlagEx(fl, FC_NOLOSEFOCUS, flstr, "NOLOSEFCS");
+        myDefFlagEx(fl, FC_NOSETACTIVE, flstr, "NOSETACT");
+        myDefFlagEx(fl, FC_NOLOSEACTIVE, flstr, "NOLOSEACT");
+        myDefFlagEx(fl, FC_NOSETSELECTION, flstr, "NOSETSEL");
+        myDefFlagEx(fl, FC_NOLOSESELECTION, flstr, "NOSETSEL");
+        debug.nospace() << "Focus(" << (focus ? "TRUE) " : "FALSE)");
+        debug.space() << "hwndFocus" << qDebugHWND(hwnd);
+        debug.nospace() << "FC(" << flstr.constData() << ")";
+        debug.space();
+        break;
+    myCaseEnd()
+
+    default:
+        debug.nospace() << "WM_" << qDebugFmtHex(qmsg.msg) << ":";
+        debug.space() << qDebugHWND(qmsg.hwnd);
+        debug << "mp1" << qmsg.mp1 << "mp2" << qmsg.mp2;
+        break;
+    }
+
+    return debug;
+
+    #undef myCaseEnd
+    #undef myCaseBegin
 }
 
Index: /trunk/src/gui/kernel/qwidget_pm.cpp
===================================================================
--- /trunk/src/gui/kernel/qwidget_pm.cpp	(revision 604)
+++ /trunk/src/gui/kernel/qwidget_pm.cpp	(revision 605)
@@ -150,6 +150,7 @@
 {
 #if defined(QT_DEBUGWIDGETMASK)
-    qDebug("qt_WinInvalidateRegionEx: hwnd=%s hwndFrom=%08lX hwndTo=%08lX",
-           qStrHWND(hwnd).toUtf8().constData(), hwndFrom, hwndTo);
+    qDebug() << "qt_WinInvalidateRegionEx: hwnd" << qDebugHWND(hwnd)
+             << "hwndFrom" << qDebugFmtHex(hwndFrom)
+             << "hwndTo" << qDebugFmtHex(hwndTo);
 #endif
 
@@ -179,6 +180,5 @@
         WinQueryWindowPos(child, &swp);
 #if defined(QT_DEBUGWIDGETMASK)
-        qDebug(" child=%s [fl=%08lX]", qStrHWND(child).toUtf8().constData(),
-               swp.fl);
+        qDebug() << " child" << qDebugHWND(child) << "fl" << qDebugFmtHex(swp.fl);
 #endif
         // proceed only if not hidden
@@ -264,7 +264,7 @@
 
 #if defined(QT_DEBUGWIDGETMASK)
-    qDebug("qt_WinProcessWindowObstacles: hwnd=%s, prcl=%p "
-           "hrgn=%08lX, op=%ld flags=%08lX",
-           qStrHWND(hwnd).toUtf8().constData(), prcl, hrgn, op, flags);
+    qDebug() << "qt_WinProcessWindowObstacles: hwnd" << qDebugHWND(hwnd)
+             << "prcl" << prcl << "hrgn" << qDebugFmtHex(hrgn)
+             << "op" << op << "flags" << qDebugFmtHex(flags);
 #endif
 
@@ -316,6 +316,6 @@
                 WinQueryWindowPos(relative, &swp);
 #if defined(QT_DEBUGWIDGETMASK)
-                qDebug(" child=%s [fl=%08lX]",
-                       qStrHWND(relative).toUtf8().constData(), swp.fl);
+                qDebug() << " child" << qDebugHWND(relative)
+                         << "fl" << qDebugFmtHex(swp.fl);
 #endif
                 // skip if hidden
@@ -356,6 +356,6 @@
             WinQueryWindowPos(relative, &swp);
 #if defined(QT_DEBUGWIDGETMASK)
-            qDebug(" sibling=%s [fl=%08lX]",
-                   qStrHWND(relative).toUtf8().constData(), swp.fl);
+            qDebug() << " sibling" << qDebugHWND(relative)
+                     << "fl" << qDebugFmtHex(swp.fl);
 #endif
             // skip if hidden
@@ -406,6 +406,6 @@
             WinQueryWindowPos(parent, &swp);
 #if defined(QT_DEBUGWIDGETMASK)
-            qDebug(" parent=%s [fl=%08lX]",
-                   qStrHWND(parent).toUtf8().constData(), swp.fl);
+            qDebug() << " parent" << qDebugHWND(parent)
+                     << "fl" << qDebugFmtHex(swp.fl);
 #endif
             delta.x += swp.x;
@@ -415,6 +415,6 @@
                 WinQueryWindowPos(relative, &swp);
 #if defined(QT_DEBUGWIDGETMASK)
-                qDebug(" ancestor=%s [fl=%08lX]",
-                       qStrHWND(relative).toUtf8().constData(), swp.fl);
+                qDebug() << " ancestor" << qDebugHWND(relative)
+                         << "fl" << qDebugFmtHex(swp.fl);
 #endif
                 // skip if hidden
@@ -468,6 +468,6 @@
 {
 #if defined(QT_DEBUGWIDGETMASK)
-    qDebug("qt_WinSetWindowPos: hwnd=%s fl=%08lX",
-           qStrHWND(hwnd).toUtf8().constData(), fl);
+    qDebug() << "qt_WinSetWindowPos: hwnd" << qDebugHWND(hwnd)
+             << "fl" << qDebugFmtHex(fl);
 #endif
 
@@ -561,7 +561,7 @@
             }
 #if defined(QT_DEBUGWIDGETMASK)
-            qDebug(" moving up? %ld", up);
-            qDebug(" hwndFrom=%s", qStrHWND(hwndFrom).toUtf8().constData());
-            qDebug(" hwndTo=%s", qStrHWND(hwndTo).toUtf8().constData());
+            qDebug() << " moving up?" << up;
+            qDebug() << " hwndFrom" << qDebugHWND(hwndFrom);
+            qDebug() << " hwndTo" << qDebugHWND(hwndTo);
 #endif
 
@@ -576,6 +576,6 @@
                     WinQueryWindowPos(sibling, &swp);
 #if defined(QT_DEBUGWIDGETMASK)
-                    qDebug(" sibling=%s [fl=%08lX]",
-                           qStrHWND(sibling).toUtf8().constData(), swp.fl);
+                    qDebug() << " sibling" << qDebugHWND(sibling)
+                             << "fl" << qDebugFmtHex(swp.fl);
 #endif
                     // proceed only if not hidden
@@ -607,6 +607,6 @@
                     WinQueryWindowPos(sibling, &swp);
 #if defined(QT_DEBUGWIDGETMASK)
-                    qDebug(" sibling=%s [fl=%08lX]",
-                           qStrHWND(sibling).toUtf8().constData(), swp.fl);
+                    qDebug() << " sibling" << qDebugHWND(sibling)
+                             << "fl" << qDebugFmtHex(swp.fl);
 #endif
                     // proceed only if not hidden
@@ -1138,11 +1138,9 @@
             }
 #if defined(QT_DEBUGWINCREATEDESTROY)
-            qDebug("|Creating top level window (frame) [%s]:\n"
-                   "|  owner = %08lX\n"
-                   "|  title = '%s'\n"
-                   "|  style = %08lX\n"
-                   "|  fcFlags = %08lX",
-                   qWidgetName(q).toUtf8().constData(), ownerw,
-                   title.constData(), fStyle, fcFlags);
+            qDebug() <<   "|Creating top level window (frame)" << q
+                     << "\n|  owner" << qDebugFmtHex(ownerw)
+                     << "\n|  title" << title
+                     << "\n|  style" << qDebugFmtHex(fStyle)
+                     << "\n|  fcFlags" << qDebugFmtHex(fcFlags);
 #endif
             fId = WinCreateWindow(HWND_DESKTOP, WC_FRAME, title, fStyle,
@@ -1150,5 +1148,5 @@
                                   &fcData, NULL);
 #if defined(QT_DEBUGWINCREATEDESTROY)
-            qDebug("|  hwnd = %08lX", fId);
+            qDebug() << "|  hwnd" << qDebugFmtHex(fId);
 #endif
             if (fId == NULLHANDLE)
@@ -1189,11 +1187,9 @@
             // create client window
 #if defined(QT_DEBUGWINCREATEDESTROY)
-            qDebug("|Creating top level window (client) [%s]:\n"
-                   "|  owner & parent = %08lX\n"
-                   "|  class = '%s'\n"
-                   "|  title = '%s'\n"
-                   "|  style = %08lX",
-                   qWidgetName(q).toUtf8().constData(), fId, className.constData(),
-                   title.constData(), style);
+            qDebug() <<   "|Creating top level window (client)" << q
+                     << "\n|  owner & parent" << qDebugFmtHex(fId)
+                     << "\n|  class" << className
+                     << "\n|  title" << title
+                     << "\n|  style" << qDebugFmtHex(style);
 #endif
             // note that we place the client on top (HWND_TOP) to exclude other
@@ -1203,10 +1199,8 @@
         } else {
 #if defined(QT_DEBUGWINCREATEDESTROY)
-            qDebug("|Creating top level window (popup) [%s]:\n"
-                   "|  class = '%s'\n"
-                   "|  title = '%s'\n"
-                   "|  style = %08lX",
-                   qWidgetName(q).toUtf8().constData(), className.constData(),
-                   title.constData(), style);
+            qDebug() <<   "|Creating top level window (popup)" << q
+                     << "\n|  class" << className
+                     << "\n|  title" << title
+                     << "\n|  style" << qDebugFmtHex(style);
 #endif
             id = WinCreateWindow(HWND_DESKTOP, className, title, style,
@@ -1214,5 +1208,5 @@
         }
 #if defined(QT_DEBUGWINCREATEDESTROY)
-        qDebug("|  hwnd = %08lX", id);
+        qDebug() << "|  hwnd" << qDebugFmtHex(id);
 #endif
         if (id == NULLHANDLE)
@@ -1327,11 +1321,9 @@
 
 #if defined(QT_DEBUGWINCREATEDESTROY)
-        qDebug("|Creating child window [%s]:\n"
-               "|  owner & parent = %08lX\n"
-               "|  class = '%s'\n"
-               "|  title = '%s'\n"
-               "|  style = %08lX",
-               qWidgetName(q).toUtf8().constData(), parentw, className.constData(),
-               title.constData(), style);
+        qDebug() <<   "|Creating child window" << q
+                 << "/n|  owner & parent" << qDebugFmtHex(parentw)
+                 << "/n|  class" << className
+                 << "/n|  title" << title
+                 << "/n|  style" << qDebugFmtHex(style);
 #endif
         id = WinCreateWindow(parentw, className, title, style,
@@ -1342,5 +1334,5 @@
                              parentw, HWND_TOP, 0, NULL, NULL);
 #if defined(QT_DEBUGWINCREATEDESTROY)
-        qDebug("|  hwnd = %08lX", id);
+        qDebug() << "|  hwnd" << qDebugFmtHex(id);
 #endif
         if (id == NULLHANDLE)
@@ -1405,8 +1397,7 @@
             }
 #if defined(QT_DEBUGWINCREATEDESTROY)
-            qDebug("|Destroying window [%s]:\n"
-                   "|  hwnd = %08lX", qWidgetName(this).toUtf8().constData(), id);
-#endif
-
+            qDebug() << "|Destroying window" << this
+                     << "\n|  hwnd"  << qDebugFmtHex(id);
+#endif
             qt_WinDestroyWindow(id);
         }
Index: /trunk/src/gui/kernel/qwindowdefs_pm.h
===================================================================
--- /trunk/src/gui/kernel/qwindowdefs_pm.h	(revision 604)
+++ /trunk/src/gui/kernel/qwindowdefs_pm.h	(revision 605)
@@ -86,46 +86,22 @@
 Q_GUI_EXPORT int qt_display_height();
 
-Q_GUI_EXPORT QWidget *qWidgetFromHWND(HWND hwnd);
+Q_GUI_EXPORT QWidget *qt_widget_from_hwnd(HWND hwnd);
 
-// For printing non-quoted QString's with QDebug
-struct Q_CORE_EXPORT QDbgStr: public QString
-{
-    inline QDbgStr(const QString &str) : QString(str) {}
-};
+// QDebug helpers for debugging various API types
 
-Q_GUI_EXPORT QDbgStr qWidgetName(QWidget *w);
-inline QDbgStr qWidgetName(HWND hwnd)
-{ return qWidgetName(qWidgetFromHWND(hwnd)); }
+// don't drag qdebug.h but require it to be included first
+#if defined(QDEBUG_H) && !defined(QT_NO_DEBUG_STREAM)
 
-Q_CORE_EXPORT QDbgStr qStrHWND(HWND hwnd);
-Q_CORE_EXPORT QDbgStr qStrHPS(HPS hps);
-Q_CORE_EXPORT QDbgStr qStrHPOINTER(HPOINTER hptr);
-Q_CORE_EXPORT QDbgStr qStrHRGN(HRGN hrgn);
-
-Q_CORE_EXPORT QDbgStr qStrQMSG(const QMSG &qmsg);
+struct QDebugHWND { HWND hwnd; };
+inline QDebugHWND qDebugHWND(HWND hwnd) { QDebugHWND d = { hwnd }; return d; }
+QDebug operator<<(QDebug debug, const QDebugHWND &d);
 
 // the following declarations require OS/2 types not defined here,
-// we don't drag them in but require qt_os2.h to be included before
+// don't drag them in as well but require qt_os2.h to be included first
 #if defined(QT_OS2_H)
 
-Q_CORE_EXPORT QDbgStr qStrRECTL(const RECTL &rcl);
-Q_CORE_EXPORT QDbgStr qStrSWP(const SWP &swp);
-
-#endif // defined(QT_OS2_H)
-
-// don't drag qdebug.h as well but require it to be included before
-#if defined(QDEBUG_H) && !defined(QT_NO_DEBUG_STREAM)
-
-// Prints a non-quoted QString
-inline QDebug operator<<(QDebug dbg, const QDbgStr &str)
-{ dbg << str.toUtf8().constData(); return dbg; }
-
-#if defined(QT_OS2_H)
-
-inline QDebug operator<<(QDebug dbg, const RECTL &rcl)
-{ dbg << qStrRECTL(rcl); return dbg; }
-
-inline QDebug operator<<(QDebug dbg, const SWP &swp)
-{ dbg << qStrSWP(swp); return dbg; }
+QDebug operator<<(QDebug debug, const RECTL &rcl);
+QDebug operator<<(QDebug debug, const SWP &swp);
+QDebug operator<<(QDebug debug, const QMSG &qmsg);
 
 #endif // defined(QT_OS2_H)
Index: /trunk/src/gui/painting/qwindowsurface_raster.cpp
===================================================================
--- /trunk/src/gui/painting/qwindowsurface_raster.cpp	(revision 604)
+++ /trunk/src/gui/painting/qwindowsurface_raster.cpp	(revision 605)
@@ -212,7 +212,6 @@
 
 #if 0
-    qDebug("QRasterWindowSurface::flush: [%s] wps %x br %d,%d/%d,%d",
-           qWidgetName(widget).toUtf8().constData(), (unsigned int)wps,
-           br.x(), br.y(), br.width(), br.height());
+    qDebug() << "QRasterWindowSurface::flush:" << widget << "wps" << wps
+             << "br" << br;
 #endif
 
@@ -248,8 +247,7 @@
                       { br.right() + 1, ih - br.top() } };
 #if 0
-    qDebug("QRasterWindowSurface::flush: [%s] ptls %ld,%ld-%ld,%ld %ld,%ld-%ld,%ld",
-           qWidgetName(widget).toUtf8().constData(),
-           ptls[0].x, ptls[0].y, ptls[1].x, ptls[1].y,
-           ptls[2].x, ptls[2].y, ptls[3].x, ptls[3].y);
+    qDebug() << "QRasterWindowSurface::flush:" << widget << "ptls"
+             << ptls[0].x << ptls[0].y << ptls[1].x << ptls[1].y
+             << ptls[2].x << ptls[2].y << ptls[3].x << ptls[3].y;
 #endif
     GpiDrawBits(wps, (PVOID) img.bits(), (PBITMAPINFO2) &bmh, 4, ptls,
@@ -277,8 +275,7 @@
                       { br.right() + 1, br.bottom() + 1 } };
 #if 0
-    qDebug("QRasterWindowSurface::flush: [%s] ptls %ld,%ld-%ld,%ld %ld,%ld-%ld,%ld",
-           qWidgetName(widget).toUtf8().constData(),
-           ptls[0].x, ptls[0].y, ptls[1].x, ptls[1].y,
-           ptls[2].x, ptls[2].y, ptls[3].x, ptls[3].y);
+    qDebug() << "QRasterWindowSurface::flush:" << widget << "ptls"
+             << ptls[0].x << ptls[0].y << ptls[1].x << ptls[1].y
+             << ptls[2].x << ptls[2].y << ptls[3].x << ptls[3].y;
 #endif
 
