6.0.0-rc4Source

QScopedValueRollback Class

template <typename T> class QScopedValueRollback

The QScopedValueRollback class resets a variable to its previous value on destruction. More…

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

List of all members, including inherited members

Public Functions

Detailed Description

A QScopedValueRollback saves the value of a variable when constructed and assigns it back when destroyed, unless commit() was called.

See also QScopeGuard.

Differences from Qt

None.

Member Function Documentation

[explicit] QScopedValueRollback::QScopedValueRollback(T &v)

Constructs a rollback that saves the current value of v and restores it on destruction.

QScopedValueRollback::QScopedValueRollback(T &v, T value)

This is an overloaded function.

Saves the current value of v, assigns value to v, and restores the saved value on destruction.

QScopedValueRollback::~QScopedValueRollback()

Assigns the saved value back to the variable.

void QScopedValueRollback::commit()

Saves the variable's current value, so that destruction restores that value instead of the original one.