QDebugStateSaver Class
カスタムQDebug 演算子のための便利なクラス。さらに...
ヘッダ | #include <QDebugStateSaver> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
パブリック関数
QDebugStateSaver(QDebug &dbg) | |
~QDebugStateSaver() |
詳細説明
QDebugQDebugStateSaver の構築時にautoInsertSpaces() が真であった場合、maybeSpace() を呼び出し、引数をスペースで区切ります。
書き込みの間の空白の自動挿入は、QDebugStateSaverが現在のブロックの間保存する設定の1つです。
内部QTextStream の設定も保存され、復元されます。そのため、QDebug 演算子で <<Qt::hex を使用しても、他のQDebug 演算子には影響しません。
QDebugStateSaverは通常、デバッグのためのoperator<<()の実装で使用されます:
QDebug operator<<(QDebug dbg, const Message &message) { const QList<QStringView> pieces = message.body().split(u"\r\n", Qt::SkipEmptyParts); if (pieces.isEmpty()) dbg.nospace() << "Message()"; else if (pieces.size() == 1) dbg.nospace() << "Message(" << pieces.first() << ")"; else dbg.nospace() << "Message(" << pieces.first() << " ...)"; return dbg; }
メンバ関数ドキュメント
QDebugStateSaver::QDebugStateSaver(QDebug &dbg)
QDebugStateSaver インスタンスを作成します。これはdbg によって現在使用されている設定を保存します。
QDebug::setAutoInsertSpaces() およびQDebug::autoInsertSpaces()も参照してください 。
[noexcept]
QDebugStateSaver::~QDebugStateSaver()
QDebugStateSaver インスタンスを破棄し、QDebugStateSaver インスタンス作成時の設定を復元する。
QDebug::setAutoInsertSpaces() およびQDebug::autoInsertSpaces()も参照 。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.