2015. 4. 2. 00:42

QDebug 소개

출처 : http://doc.qt.io/qt-5/qdebug.html

Detailed Description

자세한 설명

The QDebug class provides an output stream for debugging information.

QDebug 클래스는 디버깅 정보를 위한 출력 스트림을 제공합니다.

QDebug is used whenever the developer needs to write out debugging or tracing information to a device, file, string or console.

QDebug 는 개발자가 기기, 파일, 문자열이나 콘솔 창을 대상으로 디버깅이나 추적 정보를 쓸 필요가 있을 때 언제든 사용됩니다.

Basic Use

기본 사용

In the common case, it is useful to call the qDebug() function to obtain a default QDebug object to use for writing debugging information.

공통 적인 경우로, 디버깅 정보를 쓰기 위해 기본 QDebug 객체를 얻는 방법으로 qDebug() 함수를 쓰는 것이 유용합니다. 

    qDebug() << "Date:" << QDate::currentDate();
    qDebug() << "Types:" << QString("String") << QChar('x') << QRect(0, 10, 50, 40);
    qDebug() << "Custom coordinate type:" << coordinate;

This constructs a QDebug object using the constructor that accepts a QtMsgType value of QtDebugMsg. Similarly, the qWarning(), qCritical() and qFatal() functions also return QDebug objects for the corresponding message types.

이는 QtDebugMsg 의 QtMsgType 값을 받아 들이는 생성자를 사용하는 QDebug 객체를 만듭니다. 유사하게 qWarning(), qCritical() 과 qFatal() 함수 또한 이에 대응하는 메시지 용에 맞는 QDebug 객체를 반환합니다.

The class also provides several constructors for other situations, including a constructor that accepts a QFile or any other QIODevice subclass that is used to write debugging information to files and other devices. The constructor that accepts a QString is used to write to a string for display or serialization.

이 클래스는 경우에 따라 파일이나 다른 기기에 디버깅 정보를 쓰는데 사용되는 QFile 또는 QIODebug 서브클래스를 포함하여 몇몇 생성자들도 제공합니다. QString 을 받는 생성자는 화면에 표시 또는 (저장용으로) 직렬화를 위해 사용됩니다.

Formatting Options

형식화 옵션들

QDebug formats output so that it's easily readable. It automatically adds spaces between arguments, and adds quotes around QStringQByteArrayQChar arguments.

QDebug 은 쉽게 읽을 수 있게 출력을 형식화 합니다. 자동으로 인수들간 띄워쓰기를 추가하고 QString, QByteArray, QChar 형 인수들에게는 인용부호(" ")를 붙입니다.

You can tweak these options through the space(), nospace() and quote(), noquote() methods. Furthermore,QTextStream manipulators can be piped into a QDebug stream.

space(), nospace() 와 quote(), noquote() 를 사용하여 이런 옵션(선택사항)들을 조절할 수 있습니다. 더 나아가 QTextStream 조정자 (머니퓰레이터) 는 QDebug 스트림을 끌어들일 수 있습니다.

QDebugStateSaver limits changes to the formatting to the current scope. resetFormat() resets the options to the default ones.

QDebugStateSaver 는 현재 영역까지 형식화를 변경하는 것을 제한합니다. resetFormat() 은 기본 값으로 옵션들을 초기화 합니다.

Writing Custom Types to a Stream

스트림에 맞는 맞춤형 작성

Many standard types can be written to QDebug objects, and Qt provides support for most Qt value types. To add support for custom types, you need to implement a streaming operator, as in the following example:

QDebug 객체에 대해 많은 표준 유형들이 작성될 수 있고, Qt 는 다양한 Qt 값 유형들을 지원합니다. 맞춤형으로 추가하기 위해서는, 스트리밍 연산자를 다음의 예제와 같이 구현할 필요가 있습니다.

QDebug operator<<(QDebug dbg, const Coordinate &c)
{
    dbg.nospace() << "(" << c.x() << ", " << c.y() << ")";

    return dbg.space();
}

This is described in the Debugging Techniques and Creating Custom Qt Types documents.

이 부분은 디버깅 기술과 맞춤형 Qt 형태 문서에 설명되어 있습니다.

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


'소프트웨어 > Qt' 카테고리의 다른 글

Creating Custom Qt Types  (0) 2015.04.02
Debugging Techniques  (0) 2015.04.02
QString  (0) 2015.03.25
qPrintable  (0) 2015.03.25
windeployqt (The Windows Deployment Tool, QT 윈도우 배포도구)  (0) 2015.03.23