Home · All Namespaces · All Classes · Main Classes · Grouped Classes · Modules · Functions |
The QDebug class provides an output stream for debugging information. More...
#include <QDebug>
The QDebug class provides an output stream for debugging information.
QDebug is used whenever the developer needs to write out debugging or tracing information to a device, file, string or console.
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. Similarly, the qWarning(), qCritical() and 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 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.
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 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.
Constructs a debug stream that writes to the given device.
Constructs a debug stream that writes to the given string.
Constructs a debug stream that writes to the handler for the message type specified by type.
Constructs a copy of the other debug stream.
Flushes any pending data to be written and destroys the debug stream.
Writes a space character to the debug stream, depending on the last character sent to the stream, and returns a reference to the stream.
If the last character was a space character, this function writes a space character to the stream; otherwise, no characters are written to the stream.
See also space() and nospace().
Clears the stream's internal flag that records whether the last character was a space and returns a reference to the stream.
See also space() and maybeSpace().
Writes a space character to the debug stream and returns a reference to the stream.
The stream will record that the last character sent to the stream was a space.
See also nospace() and maybeSpace().
Writes the character, t, to the stream and returns a reference to the stream.
Writes the boolean value, t, to the stream and returns a reference to the stream.
Writes the character, t, to the stream and returns a reference to the stream.
Writes the signed short integer, i, to the stream and returns a reference to the stream.
Writes then unsigned short integer, i, to the stream and returns a reference to the stream.
Writes the signed integer, i, to the stream and returns a reference to the stream.
Writes then unsigned integer, i, to the stream and returns a reference to the stream.
Writes the signed long integer, l, to the stream and returns a reference to the stream.
Writes then unsigned long integer, l, to the stream and returns a reference to the stream.
Writes the signed 64-bit integer, i, to the stream and returns a reference to the stream.
Writes then unsigned 64-bit integer, i, to the stream and returns a reference to the stream.
Writes the 32-bit floating point number, f, to the stream and returns a reference to the stream.
Writes the 64-bit floating point number, f, to the stream and returns a reference to the stream.
Writes the '\0'-terminated string, s, to the stream and returns a reference to the stream.
Writes the string, s, to the stream and returns a reference to the stream.
Writes the string reference, s, to the stream and returns a reference to the stream.
Writes the Latin1-encoded string, s, to the stream and returns a reference to the stream.
Writes the byte array, b, to the stream and returns a reference to the stream.
Writes a pointer, p, to the stream and returns a reference to the stream.
Assigns the other debug stream to this stream and returns a reference to this stream.
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt 4.5.1 |