diff --git a/src/corelib/doc/src/includes/qdebug-toString.qdocinc b/src/corelib/doc/src/includes/qdebug-toString.qdocinc index 4602a105113..db1e1ab4537 100644 --- a/src/corelib/doc/src/includes/qdebug-toString.qdocinc +++ b/src/corelib/doc/src/includes/qdebug-toString.qdocinc @@ -5,3 +5,5 @@ This function is useful for cases where you need the textual representation of an object for debugging, but cannot use \c {operator<<}. For example: \snippet code/src_corelib_io_qdebug.cpp toString + +The string is streamed using \l nospace(). diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 48b7538c8ef..e14d31f38ab 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -179,7 +179,7 @@ public: { QString buffer; QDebug stream(&buffer); - stream << object; + stream.nospace() << object; return buffer; } @@ -188,7 +188,7 @@ public: { QString buffer; QDebug stream(&buffer); - stream << object; + stream.nospace() << object; return buffer; } }; diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 7b9e614cf74..4260accfd07 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -748,7 +748,7 @@ void tst_QDebug::toString() const MyPoint point(3, 4); QString expectedString; QDebug stream(&expectedString); - stream << point; + stream.nospace() << point; QCOMPARE(QDebug::toString(point), expectedString); } @@ -758,7 +758,7 @@ void tst_QDebug::toString() const qobject.setObjectName("test"); QString expectedString; QDebug stream(&expectedString); - stream << &qobject; + stream.nospace() << &qobject; QCOMPARE(QDebug::toString(&qobject), expectedString); } }