Update documentation snippets related to QDebug.

Use QDebugStateSaver to store the formatting state and fix the return
statement to return the unmodified stream.

Change-Id: I476d13c5487a89f263dcc11334fc67c85d9433f5
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
Friedemann Kleint 2015-03-31 15:49:08 +02:00
parent 7c2360b762
commit f53621af05
2 changed files with 8 additions and 6 deletions

View File

@ -51,11 +51,12 @@ public:
};
//! [0]
QDebug operator<<(QDebug dbg, const Coordinate &c)
QDebug operator<<(QDebug debug, const Coordinate &c)
{
dbg.nospace() << "(" << c.x() << ", " << c.y() << ")";
QDebugStateSaver saver(debug);
debug.nospace() << '(' << c.x() << ", " << c.y() << ')';
return dbg.space();
return debug;
}
//! [0]

View File

@ -59,10 +59,11 @@ struct UsbEntry {
int classtype;
};
QDebug operator<<(QDebug &dbg, const UsbEntry &entry)
QDebug operator<<(QDebug &debug, const UsbEntry &entry)
{
dbg.nospace() << "" << entry.id << " (" << entry.classtype << ")";
return dbg.space();
QDebugStateSaver saver(debug);
debug.nospace() << "" << entry.id << " (" << entry.classtype << ')';
return debug;
}
QList<UsbEntry> usbEntries() {