From 5b0be0c2173e365b2484844ffd0b23ead5f9a48a Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 20 Jun 2014 15:35:34 +0200 Subject: QDebug: Improve QDebug stream operator for QFlags Use the built-in hex, showbase manipulator to format the number in hex. Also, apply nospace() only once. Change-Id: Id4b3d5f082ad13f52c8711408d7ec609bec3a621 Reviewed-by: Alex Blasche --- src/corelib/io/qdebug.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index d224359724..6b81d9431f 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -259,21 +259,21 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache &cache) template inline QDebug operator<<(QDebug debug, const QFlags &flags) { - const bool oldSetting = debug.autoInsertSpaces(); - debug.nospace() << "QFlags("; + QDebugStateSaver saver(debug); + debug.resetFormat(); + debug.nospace() << "QFlags(" << hex << showbase; bool needSeparator = false; for (uint i = 0; i < sizeof(T) * 8; ++i) { if (flags.testFlag(T(1 << i))) { if (needSeparator) - debug.nospace() << '|'; + debug << '|'; else needSeparator = true; - debug.nospace() << "0x" << QByteArray::number(typename QFlags::Int(1) << i, 16).constData(); + debug << (typename QFlags::Int(1) << i); } } debug << ')'; - debug.setAutoInsertSpaces(oldSetting); - return debug.maybeSpace(); + return debug; } QT_END_NAMESPACE -- cgit v1.2.3