QDebugStateSaver Class
The QDebugStateSaver class saves and restores the formatting state of a QDebug stream. More…
| Header | #include <QDebugStateSaver> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Functions
| QDebugStateSaver(QDebug &dbg) | |
| ~QDebugStateSaver() |
Detailed Description
Construct one at the start of an operator<<(QDebug, const T &) that changes the spacing or quoting of the stream. The settings are restored when it is destroyed, so the caller's settings are not affected:
QDebug operator<<(QDebug debug, const Point &p) {
QDebugStateSaver saver(debug);
debug.nospace() << "Point(" << p.x << ", " << p.y << ')';
return debug;
}
See also QDebug.
Differences from Qt
None.
Member Function Documentation
QDebugStateSaver::QDebugStateSaver(QDebug &dbg)
Saves the formatting state of dbg.
QDebugStateSaver::~QDebugStateSaver()
Restores the formatting state of the stream.