QDebug 类

QDebug 类为调试信息提供输出流。 更多...

头: #include <QDebug>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
继承: QIODeviceBase
继承者:

QQmlInfo

公共类型

enum VerbosityLevel { MinimumVerbosity, DefaultVerbosity, MaximumVerbosity }

公共函数

QDebug (QIODevice * device )
QDebug (QString * string )
QDebug (QtMsgType t )
QDebug (const QDebug & o )
~QDebug ()
bool autoInsertSpaces () const
QDebug & maybeQuote (char c = '"')
QDebug & maybeSpace ()
QDebug & noquote ()
QDebug & nospace ()
QDebug & quote ()
(从 6.7 起) bool quoteStrings () const
QDebug & resetFormat ()
void setAutoInsertSpaces (bool b )
(从 6.7 起) void setQuoteStrings (bool b )
void setVerbosity (int verbosityLevel )
QDebug & space ()
void swap (QDebug & other )
int verbosity () const
QDebug & verbosity (int verbosityLevel )
(从 6.0 起) QDebug & operator<< (QByteArrayView t )
QDebug & operator<< (QChar t )
QDebug & operator<< (QLatin1StringView t )
QDebug & operator<< (QStringView s )
(从 6.0 起) QDebug & operator<< (QUtf8StringView s )
(从 6.7 起) QDebug & operator<< (T i )
(从 6.7 起) QDebug & operator<< (T i )
QDebug & operator<< (bool t )
QDebug & operator<< (char t )
QDebug & operator<< (char16_t t )
QDebug & operator<< (char32_t t )
QDebug & operator<< (const QByteArray & t )
QDebug & operator<< (const QString & t )
QDebug & operator<< (const char * t )
(从 6.0 起) QDebug & operator<< (const char16_t * t )
(从 6.5 起) QDebug & operator<< (const std::basic_string<Char, Args...> & s )
(从 6.7 起) QDebug & operator<< (const std::optional<T> & opt )
(从 6.9 起) QDebug & operator<< (const std::tuple<Ts...> & tuple )
QDebug & operator<< (const void * t )
QDebug & operator<< (double t )
QDebug & operator<< (float t )
QDebug & operator<< (int t )
QDebug & operator<< (long t )
QDebug & operator<< (qint64 t )
QDebug & operator<< (quint64 t )
QDebug & operator<< (short t )
(从 6.5 起) QDebug & operator<< (std::basic_string_view<Char, Args...> s )
(从 6.6 起) QDebug & operator<< (std::chrono::duration<Rep, Period> duration )
(从 6.7 起) QDebug & operator<< (std::nullopt_t)
QDebug & operator<< (unsigned int t )
QDebug & operator<< (unsigned long t )
QDebug & operator<< (unsigned short t )
QDebug & operator= (const QDebug & other )

静态公共成员

(从 6.9 起) QByteArray toBytes (const T & object )
(从 6.0 起) QString toString (const T & object )
QDebug operator<< (QDebug debug , const QList<T> & list )
QDebug operator<< (QDebug debug , const QMap<Key, T> & map )
QDebug operator<< (QDebug debug , const QMultiHash<Key, T> & hash )
QDebug operator<< (QDebug debug , const QMultiMap<Key, T> & map )
QDebug operator<< (QDebug debug , const QSet<T> & set )
(从 6.3 起) QDebug operator<< (QDebug debug , const QVarLengthArray<T, P> & array )
(从 6.9 起) QDebug operator<< (QDebug debug , const std::array<T, N> & array )
QDebug operator<< (QDebug debug , const std::list<T, Alloc> & vec )
QDebug operator<< (QDebug debug , const std::map<Key, T, Compare, Alloc> & map )
QDebug operator<< (QDebug debug , const std::multimap<Key, T, Compare, Alloc> & map )
(从 6.9 起) QDebug operator<< (QDebug debug , const std::multiset<Key, Compare, Alloc> & multiset )
QDebug operator<< (QDebug debug , const std::pair<T1, T2> & pair )
(从 6.9 起) QDebug operator<< (QDebug debug , const std::set<Key, Compare, Alloc> & set )
(从 6.9 起) QDebug operator<< (QDebug debug , const std::unordered_map<Key, T, Hash, KeyEqual, Alloc> & map )
(从 6.9 起) QDebug operator<< (QDebug debug , const std::unordered_set<Key, Hash, KeyEqual, Alloc> & unordered_set )
QDebug operator<< (QDebug debug , const std::vector<T, Alloc> & vec )
(从 6.9 起) QDebug operator<< (QDebug debug , T t )
QDebug operator<< (QDebug debug , const QContiguousCache<T> & cache )
QDebug operator<< (QDebug debug , const QFlags<T> & flags )
QDebug operator<< (QDebug debug , const QHash<Key, T> & hash )

QDebug qCritical ()
QDebug qDebug ()
QDebug qFatal ()
QDebug qInfo ()
QDebug qWarning ()

详细描述

就会使用 QDebug,每当开发者需要把调试 (或跟踪) 信息写入输出到设备、文件、字符串或控制台时。

基本用法

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() << "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 。同样, qInfo (), qWarning (), qCritical () 和 qFatal () functions also return QDebug objects for the corresponding message types.

The class also provides several constructors for other situations, including a constructor that accepts a QFile 或任何其它 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.

格式化选项

QDebug formats output so that it's easily readable. It automatically adds spaces between arguments, and adds quotes around QString , QByteArray , QChar 自变量。

可以微调这些选项透过 space (), nospace () 和 quote (), noquote () 方法。此外, QTextStream 操作符 可以管道到 QDebug 流。

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

把自定义类型写入流

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 operator<<(QDebug debug, const Coordinate &c)
{
    QDebugStateSaver saver(debug);
    debug.nospace() << '(' << c.x() << ", " << c.y() << ')';
    return debug;
}
					

This is described in the 调试技术 and 创建自定义 Qt 类型 documents.

成员类型文档编制

enum QDebug:: VerbosityLevel

此枚举描述冗余级别的范围。

常量
QDebug::MinimumVerbosity 0
QDebug::DefaultVerbosity 2
QDebug::MaximumVerbosity 7

另请参阅 verbosity () 和 setVerbosity ().

成员函数文档编制

[since 6.5] template <typename Char, typename... Args> QDebug &QDebug:: operator<< (const std::basic_string < Char , Args ...> & s )

[since 6.5] template <typename Char, typename... Args> QDebug &QDebug:: operator<< ( std::basic_string_view < Char , Args ...> s )

Writes the string or string-view s to the stream and returns a reference to the stream.

These operators only participate in overload resolution if Char 是某一

  • char
  • char16_t
  • wchar_t

这些函数在 Qt 6.5 引入。

[since 6.7] template <typename T, QDebug::if_qint128<T> = true> QDebug &QDebug:: operator<< ( T i )

[since 6.7] template <typename T, QDebug::if_quint128<T> = true> QDebug &QDebug:: operator<< ( T i )

Prints the textual representation of the 128-bit integer i .

注意: This operator is only available if Qt supports 128-bit integer types. If 128-bit integer types are available in your build, but the Qt libraries were compiled without, the operator will print a warning instead.

注意: Because the operator is a function template, no implicit conversions are performed on its argument. It must be exactly qint128/quint128.

这些函数在 Qt 6.7 引入。

另请参阅 QT_SUPPORTS_INT128 .

[explicit] QDebug:: QDebug ( QIODevice * device )

Constructs a debug stream that writes to the given device .

[explicit] QDebug:: QDebug ( QString * string )

Constructs a debug stream that writes to the given string .

[explicit] QDebug:: QDebug ( QtMsgType t )

Constructs a debug stream that writes to the handler for the message type t .

QDebug:: QDebug (const QDebug & o )

Constructs a copy of the other debug stream o .

[noexcept] QDebug:: ~QDebug ()

Flushes any pending data to be written and destroys the debug stream.

bool QDebug:: autoInsertSpaces () const

返回 true 若此 QDebug instance will automatically insert spaces between writes.

另请参阅 setAutoInsertSpaces () 和 QDebugStateSaver .

QDebug &QDebug:: maybeQuote ( char c = '"')

Writes a character c to the debug stream, depending on the current setting for automatic insertion of quotes, and returns a reference to the stream.

默认字符是双引号 " .

另请参阅 quote () 和 noquote ().

QDebug &QDebug:: maybeSpace ()

Writes a space character to the debug stream, depending on the current setting for automatic insertion of spaces, and returns a reference to the stream.

另请参阅 space () 和 nospace ().

QDebug &QDebug:: noquote ()

Disables automatic insertion of quotation characters around QChar , QString and QByteArray contents and returns a reference to the stream.

When quoting is disabled, these types are printed without quotation characters and without escaping of non-printable characters.

另请参阅 quote () 和 maybeQuote ().

QDebug &QDebug:: nospace ()

Disables automatic insertion of spaces and returns a reference to the stream.

另请参阅 space () 和 maybeSpace ().

QDebug &QDebug:: quote ()

Enables automatic insertion of quotation characters around QChar , QString and QByteArray contents and returns a reference to the stream.

Quoting is enabled by default.

另请参阅 noquote () 和 maybeQuote ().

[noexcept, since 6.7] bool QDebug:: quoteStrings () const

返回 true 若此 QDebug instance will quote strings streamed into it (which is the default).

该函数在 Qt 6.7 引入。

另请参阅 QDebugStateSaver , quote (), noquote (),和 setQuoteStrings ().

QDebug &QDebug:: resetFormat ()

Resets the stream formatting options, bringing it back to its original constructed state.

另请参阅 space () 和 quote ().

void QDebug:: setAutoInsertSpaces ( bool b )

Enables automatic insertion of spaces between writes if b is true; otherwise automatic insertion of spaces is disabled.

另请参阅 autoInsertSpaces () 和 QDebugStateSaver .

[since 6.7] void QDebug:: setQuoteStrings ( bool b )

Enables quoting of strings streamed into this QDebug instance if b is true ; otherwise quoting is disabled.

The default is to quote strings.

该函数在 Qt 6.7 引入。

另请参阅 QDebugStateSaver , quote (), noquote (),和 quoteStrings ().

void QDebug:: setVerbosity ( int verbosityLevel )

Sets the verbosity of the stream to verbosityLevel .

允许范围是从 0 到 7。默认值为 2。

另请参阅 verbosity () 和 VerbosityLevel .

QDebug &QDebug:: space ()

Writes a space character to the debug stream and returns a reference to the stream.

The stream remembers that automatic insertion of spaces is enabled for future writes.

另请参阅 nospace () 和 maybeSpace ().

[noexcept] void QDebug:: swap ( QDebug & other )

Swaps this debug stream instance with other 。此操作很快且从不失败。

[static, since 6.9] template <typename T> QByteArray QDebug:: toBytes (const T & object )

This is equivalent to passing object to QDebug::toString(object).toUtf8() , but more efficient.

该函数在 Qt 6.9 引入。

另请参阅 toString ().

[static, since 6.0] template <typename T> QString QDebug:: toString (const T & object )

object QDebug instance that operates on a string, and then returns that string.

This function is useful for cases where you need the textual representation of an object for debugging, but cannot use operator<< 。例如:

    QTRY_VERIFY2(list.isEmpty(), qPrintable(QString::fromLatin1(
        "Expected list to be empty, but it has the following items: %1")).arg(QDebug::toString(list)));
					

The string is streamed using nospace ().

该函数在 Qt 6.0 引入。

另请参阅 toBytes ().

int QDebug:: verbosity () const

返回调试流的冗余。

Streaming operators can check the value to decide whether verbose output is desired and print more information depending on the level. Higher values indicate that more information is desired.

允许范围是从 0 到 7。默认值为 2。

另请参阅 setVerbosity () 和 VerbosityLevel .

QDebug &QDebug:: verbosity ( int verbosityLevel )

Sets the verbosity of the stream to verbosityLevel 并返回流引用。

允许范围是从 0 到 7。默认值为 2。

另请参阅 verbosity (), setVerbosity (),和 VerbosityLevel .

[since 6.0] QDebug &QDebug:: operator<< ( QByteArrayView t )

Writes the data of the observed byte array, t ,到流并返回流引用。

Normally, QDebug prints the data inside quotes and transforms control or non-US-ASCII characters to their C escape sequences (\xAB). This way, the output is always 7-bit clean and the string can be copied from the output and pasted back into C++ sources, if necessary.

To print non-printable characters without transformation, enable the noquote () functionality. Note that some QDebug backends might not be 8-bit clean.

QByteArray overload for examples.

该函数在 Qt 6.0 引入。

QDebug &QDebug:: operator<< ( QChar t )

Writes the character, t , to the stream and returns a reference to the stream. Normally, QDebug prints control characters and non-US-ASCII characters as their C escape sequences or their Unicode value (\u1234). To print non-printable characters without transformation, enable the noquote () functionality, but note that some QDebug backends may not be 8-bit clean and may not be able to represent t .

QDebug &QDebug:: operator<< ( QLatin1StringView t )

写入字符串 t , to the stream and returns a reference to the stream. Normally, QDebug prints the string inside quotes and transforms non-printable characters to their Unicode values (\u1234).

To print non-printable characters without transformation, enable the noquote () functionality. Note that some QDebug backends might not be 8-bit clean.

QString overload for examples.

QDebug &QDebug:: operator<< ( QStringView s )

Writes the string view, s , to the stream and returns a reference to the stream. Normally, QDebug prints the string inside quotes and transforms non-printable characters to their Unicode values (\u1234).

To print non-printable characters without transformation, enable the noquote () functionality. Note that some QDebug backends might not be 8-bit clean.

QString overload for examples.

[since 6.0] QDebug &QDebug:: operator<< ( QUtf8StringView s )

Writes the string view, s ,到流并返回流引用。

Normally, QDebug prints the data inside quotes and transforms control or non-US-ASCII characters to their C escape sequences (\xAB). This way, the output is always 7-bit clean and the string can be copied from the output and pasted back into C++ sources, if necessary.

To print non-printable characters without transformation, enable the noquote () functionality. Note that some QDebug backends might not be 8-bit clean.

该函数在 Qt 6.0 引入。

QDebug &QDebug:: operator<< ( bool t )

Writes the boolean value, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( char t )

Writes the character, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( char16_t t )

Writes the UTF-16 character, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( char32_t t )

Writes the UTF-32 character, t ,到流并返回流引用。

QDebug &QDebug:: operator<< (const QByteArray & t )

Writes the byte array, t , to the stream and returns a reference to the stream. Normally, QDebug prints the array inside quotes and transforms control or non-US-ASCII characters to their C escape sequences (\xAB). This way, the output is always 7-bit clean and the string can be copied from the output and pasted back into C++ sources, if necessary.

To print non-printable characters without transformation, enable the noquote () functionality. Note that some QDebug backends might not be 8-bit clean.

输出范例:

    QByteArray ba;
    ba = "a";
    qDebug().noquote() << ba;    // prints: a
    qDebug() << ba;              // prints: "a"
    ba = "\"a\r\n\"";
    qDebug() << ba;              // prints: "\"a\r\n\""
    ba = "\033";                 // escape character
    qDebug() << ba;              // prints: "\x1B"
    ba = "\xC3\xA1";
    qDebug() << ba;              // prints: "\xC3\xA1"
    ba = QByteArray("a\0b", 3);
    qDebug() << ba               // prints: "\a\x00""b"
					

Note how QDebug needed to close and reopen the string in the way C and C++ languages concatenate string literals so that the letter 'b' is not interpreted as part of the previous hexadecimal escape sequence.

QDebug &QDebug:: operator<< (const QString & t )

写入字符串 t , to the stream and returns a reference to the stream. Normally, QDebug prints the string inside quotes and transforms non-printable characters to their Unicode values (\u1234).

To print non-printable characters without transformation, enable the noquote () functionality. Note that some QDebug backends might not be 8-bit clean.

输出范例:

    QString s;
    s = "a";
    qDebug().noquote() << s;    // prints: a
    qDebug() << s;              // prints: "a"
    s = "\"a\r\n\"";
    qDebug() << s;              // prints: "\"a\r\n\""
    s = "\033";                 // escape character
    qDebug() << s;              // prints: "\u001B"
    s = "\u00AD";               // SOFT HYPHEN
    qDebug() << s;              // prints: "\u00AD"
    s = "\u00E1";               // LATIN SMALL LETTER A WITH ACUTE
    qDebug() << s;              // prints: "á"
    s = "a\u0301";              // "a" followed by COMBINING ACUTE ACCENT
    qDebug() << s;              // prints: "á";
    s = "\u0430\u0301";         // CYRILLIC SMALL LETTER A followed by COMBINING ACUTE ACCENT
    qDebug() << s;              // prints: "а́"
					

QDebug &QDebug:: operator<< (const char * t )

Writes the '\0'-terminated UTF-8 string, t , to the stream and returns a reference to the stream. The string is never quoted or escaped for the output. Note that QDebug buffers internally as UTF-16 and may need to transform to 8-bit using the locale's codec in order to use some backends, which may cause garbled output (mojibake). Restricting to US-ASCII strings is recommended.

[since 6.0] QDebug &QDebug:: operator<< (const char16_t * t )

Writes the u'\0'-terminated UTF-16 string, t , to the stream and returns a reference to the stream. The string is never quoted or escaped for the output. Note that QDebug buffers internally as UTF-16 and may need to transform to 8-bit using the locale's codec in order to use some backends, which may cause garbled output (mojibake). Restricting to US-ASCII strings is recommended.

该函数在 Qt 6.0 引入。

[since 6.7] template <typename T, QDebug::if_streamable<T> = true> QDebug &QDebug:: operator<< (const std::optional < T > & opt )

Writes the contents of opt (或 nullopt if not set) to this stream. T needs to support streaming into QDebug .

该函数在 Qt 6.7 引入。

[since 6.9] template <typename... Ts, QDebug::if_streamable<Ts...> = true> QDebug &QDebug:: operator<< (const std::tuple < Ts ...> & tuple )

Writes the contents of tuple to the stream. All Ts... need to support streaming into QDebug .

该函数在 Qt 6.9 引入。

QDebug &QDebug:: operator<< (const void * t )

写入指针 t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( double t )

Writes the 64-bit floating point number, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( float t )

Writes the 32-bit floating point number, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( int t )

Writes the signed integer, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( long t )

Writes the signed long integer, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( qint64 t )

Writes the signed 64-bit integer, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( quint64 t )

Writes then unsigned 64-bit integer, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( short t )

Writes the signed short integer, t ,到流并返回流引用。

[since 6.6] template <typename Rep, typename Period> QDebug &QDebug:: operator<< ( std::chrono::duration < Rep , Period > duration )

Prints the time duration duration to the stream and returns a reference to the stream. The printed string is the numeric representation of the period followed by the time unit, similar to what the C++ Standard Library would produce with std::ostream .

The unit is not localized.

该函数在 Qt 6.6 引入。

[since 6.7] QDebug &QDebug:: operator<< ( std::nullopt_t )

Writes nullopt to the stream.

该函数在 Qt 6.7 引入。

QDebug &QDebug:: operator<< ( unsigned int t )

Writes then unsigned integer, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( unsigned long t )

Writes then unsigned long integer, t ,到流并返回流引用。

QDebug &QDebug:: operator<< ( unsigned short t )

Writes then unsigned short integer, t ,到流并返回流引用。

QDebug &QDebug:: operator= (const QDebug & other )

赋值 other debug stream to this stream and returns a reference to this stream.

相关非成员

template <typename T> QDebug operator<< ( QDebug debug , const QList < T > & list )

Writes the contents of list to debug . T needs to support streaming into QDebug .

template <typename Key, typename T> QDebug operator<< ( QDebug debug , const QMap < Key , T > & map )

Writes the contents of map to debug . Both Key and T need to support streaming into QDebug .

template <typename Key, typename T> QDebug operator<< ( QDebug debug , const QMultiHash < Key , T > & hash )

Writes the contents of hash to debug . Both Key and T need to support streaming into QDebug .

template <typename Key, typename T> QDebug operator<< ( QDebug debug , const QMultiMap < Key , T > & map )

Writes the contents of map to debug . Both Key and T need to support streaming into QDebug .

template <typename T> QDebug operator<< ( QDebug debug , const QSet < T > & set )

Writes the contents of set to debug . T needs to support streaming into QDebug .

[since 6.3] template <typename T, qsizetype P> QDebug operator<< ( QDebug debug , const QVarLengthArray < T , P > & array )

Writes the contents of array to debug . T needs to support streaming into QDebug .

该函数在 Qt 6.3 引入。

[since 6.9] template <typename T, std::size_t N> QDebug operator<< ( QDebug debug , const std::array < T , N > & array )

Writes the contents of array to debug . T needs to support streaming into QDebug .

该函数在 Qt 6.9 引入。

template <typename T, typename Alloc> QDebug operator<< ( QDebug debug , const std::list < T , Alloc > & vec )

Writes the contents of list vec to debug . T needs to support streaming into QDebug .

template <typename Key, typename T, typename Compare, typename Alloc> QDebug operator<< ( QDebug debug , const std::map < Key , T , 比较 , Alloc > & map )

Writes the contents of map to debug . Both Key and T need to support streaming into QDebug .

template <typename Key, typename T, typename Compare, typename Alloc> QDebug operator<< ( QDebug debug , const std::multimap < Key , T , 比较 , Alloc > & map )

Writes the contents of map to debug . Both Key and T need to support streaming into QDebug .

[since 6.9] template <typename Key, typename Compare, typename Alloc> QDebug operator<< ( QDebug debug , const std::multiset < Key , 比较 , Alloc > & multiset )

Writes the contents of multiset to debugKey type needs to support streaming into QDebug .

该函数在 Qt 6.9 引入。

template <typename T1, typename T2> QDebug operator<< ( QDebug debug , const std::pair < T1 , T2 > & pair )

Writes the contents of pair to debug . Both T1 and T2 need to support streaming into QDebug .

[since 6.9] template <typename Key, typename Compare, typename Alloc> QDebug operator<< ( QDebug debug , const std::set < Key , 比较 , Alloc > & set )

Writes the contents of set to debugKey type needs to support streaming into QDebug .

该函数在 Qt 6.9 引入。

[since 6.9] template <typename Key, typename T, typename Hash, typename KeyEqual, typename Alloc> QDebug operator<< ( QDebug debug , const std::unordered_map < Key , T , Hash , KeyEqual , Alloc > & map )

Writes the contents of map to debug . Both Key and T need to support streaming into QDebug .

该函数在 Qt 6.9 引入。

[since 6.9] template <typename Key, typename Hash, typename KeyEqual, typename Alloc> QDebug operator<< ( QDebug debug , const std::unordered_set < Key , Hash , KeyEqual , Alloc > & unordered_set )

Writes the contents of unordered_set to debugKey type needs to support streaming into QDebug .

该函数在 Qt 6.9 引入。

template <typename T, typename Alloc> QDebug operator<< ( QDebug debug , const std::vector < T , Alloc > & vec )

Writes the contents of vector vec to debug . T needs to support streaming into QDebug .

[since 6.9] template <typename T, QDebug::if_ordering_type<T> = true> QDebug operator<< ( QDebug debug , T t )

Prints the Qt or std ordering value tdebug 对象。

约束

Participates in overload resolution only if T is one of <Qt/Std>::<weak/partial/strong>_ordering.

该函数在 Qt 6.9 引入。

template <typename T> QDebug operator<< ( QDebug debug , const QContiguousCache < T > & cache )

Writes the contents of cache to debug . T needs to support streaming into QDebug .

template <typename T> QDebug operator<< ( QDebug debug , const QFlags < T > & flags )

写入 flags to debug .

template <typename Key, typename T> QDebug operator<< ( QDebug debug , const QHash < Key , T > & hash )

Writes the contents of hash to debug . Both Key and T need to support streaming into QDebug .

宏文档编制

QDebug qCritical ()

返回 QDebug object that logs a critical message to the central message handler.

范例:

qCritical() << "Brush:" << myQBrush << "Other value:" << i;
					

Using qCritical() is an alternative to qCritical (const char *, ...), which follows the printf paradigm.

注意, QDebug and the type specific stream operators do add various formatting to make the debug message easier to read. See the formatting options 文档编制了解更多细节。

For debugging purposes, it is sometimes convenient to let the program abort for critical messages. This allows you then to inspect the core dump, or attach a debugger - see also qFatal (). To enable this, set the environment variable QT_FATAL_CRITICALS to a number n . The program terminates then for the n-th critical message. That is, if the environment variable is set to 1, it will terminate on the first call; if it contains the value 10, it will exit on the 10th call. Any non-numeric value in the environment variable is equivalent to 1.

注意: 此宏是 线程安全 .

另请参阅 qCritical (const char *, ...) and qCCritical ().

QDebug qDebug ()

返回 QDebug object that logs a debug message to the central message handler.

范例:

qDebug() << "Brush:" << myQBrush << "Other value:" << i;
					

Using qDebug() is an alternative to qDebug (const char *, ...), which follows the printf paradigm.

注意, QDebug and the type specific stream operators do add various formatting to make the debug message easier to read. See the formatting options 文档编制了解更多细节。

此函数什么都不做,若 QT_NO_DEBUG_OUTPUT was defined during compilation.

注意: 此宏是 线程安全 .

另请参阅 qDebug (const char *, ...) and qCDebug ().

QDebug qFatal ()

返回 QDebug object that logs a fatal message to the central message handler.

Using qFatal() is an alternative to qFatal (const char *, ...), which follows the printf paradigm.

注意, QDebug and the type specific stream operators do add various formatting to make the debug message easier to read. See the formatting options 文档编制了解更多细节。

若正使用 默认消息处理程序 , the returned stream will abort to create a core dump. On Windows, for debug builds, this function will report a _CRT_ERROR enabling you to connect a debugger to the application.

注意: 此宏是 线程安全 .

另请参阅 qFatal (const char *, ...) and qCFatal ().

QDebug qInfo ()

返回 QDebug object that logs an informational message to the central message handler.

范例:

qInfo() << "Brush:" << myQBrush << "Other value:" << i;
					

Using qInfo() is an alternative to qInfo (const char *, ...), which follows the printf paradigm.

注意, QDebug and the type specific stream operators do add various formatting to make the debug message easier to read. See the formatting options 文档编制了解更多细节。

此函数什么都不做,若 QT_NO_INFO_OUTPUT was defined during compilation.

注意: 此宏是 线程安全 .

另请参阅 qInfo (const char *, ...) and qCInfo ().

QDebug qWarning ()

返回 QDebug object that logs a warning message to the central message handler.

范例:

qWarning() << "Brush:" << myQBrush << "Other value:" << i;
					

Using qWarning() is an alternative to qWarning (const char *, ...), which follows the printf paradigm.

注意, QDebug and the type specific stream operators do add various formatting to make the debug message easier to read. See the formatting options 文档编制了解更多细节。

此函数什么都不做,若 QT_NO_WARNING_OUTPUT was defined during compilation.

For debugging purposes, it is sometimes convenient to let the program abort for warning messages. This allows you then to inspect the core dump, or attach a debugger - see also qFatal (). To enable this, set the environment variable QT_FATAL_WARNINGS to a number n . The program terminates then for the n-th warning. That is, if the environment variable is set to 1, it will terminate on the first call; if it contains the value 10, it will exit on the 10th call. Any non-numeric value in the environment variable is equivalent to 1.

注意: 此宏是 线程安全 .

另请参阅 qWarning (const char *, ...) and qCWarning ().