이 페이지에서

QDebugStateSaver Class

QDebug 의 사용자 정의 연산자를 위한 편의 클래스. 더 보기...

헤더: #include <QDebugStateSaver>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

공개 함수

상세 설명

QDebug 에서 사용하는 설정을 저장하고, 소멸 시 이를 복원한 다음, QDebugStateSaver 생성 시점에 autoInsertSpaces()가 true였던 경우, 인수를 공백으로 구분하기 위해 maybeSpace()를 호출합니다.

쓰기 작업 사이에 공백을 자동으로 삽입하는 기능은 QDebugStateSaver가 현재 블록이 지속되는 동안 저장하는 설정 중 하나입니다.

내부 QTextStream 의 설정도 저장 및 복원되므로, QDebug 연산자에서 << Qt::hex 를 사용해도 다른 QDebug 연산자에는 영향을 미치지 않습니다.

QDebugStateSaver는 일반적으로 디버깅을 위한 연산자 <<() 구현에 사용됩니다:

QDebug operator<<(QDebug dbg, const Message &message)
{
    QDebugStateSaver saver(dbg);
    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)

dbg 에서 현재 사용 중인 설정을 저장하는 QDebugStateSaver 인스턴스를 생성합니다.

QDebug::setAutoInsertSpaces() 및 QDebug::autoInsertSpaces()도 참조하십시오 .

[noexcept] QDebugStateSaver::~QDebugStateSaver()

QDebugStateSaver 인스턴스를 삭제하며, 이로 인해 QDebugStateSaver 인스턴스가 생성될 당시 사용되었던 설정으로 복원됩니다.

QDebug::setAutoInsertSpaces() 및 QDebug::autoInsertSpaces()도 참조하십시오 .

© 2026 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.