6.0.0-rc4Source

QDebugStateSaver Class

The QDebugStateSaver class saves and restores the formatting state of a QDebug stream. More…

Header#include <QDebugStateSaver>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt Core C++ Classes

List of all members, including inherited members

Public Functions

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

[explicit] QDebugStateSaver::QDebugStateSaver(QDebug &dbg)

Saves the formatting state of dbg.

QDebugStateSaver::~QDebugStateSaver()

Restores the formatting state of the stream.