<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- qdebug.cpp --> <head> <title>Qt 4.6: QDebug Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <a name="//apple_ref/cpp/cl//QDebug"></a> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QDebug Class Reference<br /><span class="small-subtitle">[<a href="qtcore.html">QtCore</a> module]</span> </h1> <p>The QDebug class provides an output stream for debugging information. <a href="#details">More...</a></p> <pre> #include <QDebug></pre><ul> <li><a href="qdebug-members.html">List of all members, including inherited members</a></li> </ul> <hr /> <a name="public-functions"></a> <h2>Public Functions</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#QDebugx">QDebug</a></b> ( QIODevice * <i>device</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#QDebug-2">QDebug</a></b> ( QString * <i>string</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#QDebug-3">QDebug</a></b> ( QtMsgType <i>type</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#QDebug-4">QDebug</a></b> ( const QDebug & <i>other</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#dtor.QDebug">~QDebug</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#maybeSpace">maybeSpace</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#nospace">nospace</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#space">space</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt">operator<<</a></b> ( QChar <i>t</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-3">operator<<</a></b> ( bool <i>t</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-4">operator<<</a></b> ( char <i>t</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-5">operator<<</a></b> ( signed short <i>i</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-6">operator<<</a></b> ( unsigned short <i>i</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-7">operator<<</a></b> ( signed int <i>i</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-8">operator<<</a></b> ( unsigned int <i>i</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-9">operator<<</a></b> ( signed long <i>l</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-10">operator<<</a></b> ( unsigned long <i>l</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-11">operator<<</a></b> ( qint64 <i>i</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-12">operator<<</a></b> ( quint64 <i>i</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-13">operator<<</a></b> ( float <i>f</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-14">operator<<</a></b> ( double <i>f</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-15">operator<<</a></b> ( const char * <i>s</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-16">operator<<</a></b> ( const QString & <i>s</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-17">operator<<</a></b> ( const QStringRef & <i>s</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-18">operator<<</a></b> ( const QLatin1String & <i>s</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-19">operator<<</a></b> ( const QByteArray & <i>b</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-lt-lt-20">operator<<</a></b> ( const void * <i>p</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDebug & </td><td class="memItemRight" valign="bottom"><b><a href="qdebug.html#operator-eq">operator=</a></b> ( const QDebug & <i>other</i> )</td></tr> </table> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The QDebug class provides an output stream for debugging information.</p> <p>QDebug is used whenever the developer needs to write out debugging or tracing information to a device, file, string or console.</p> <a name="basic-use"></a> <h3>Basic Use</h3> <p>In the common case, it is useful to call the <a href="qtglobal.html#qDebug">qDebug</a>() function to obtain a default QDebug object to use for writing debugging information.</p> <pre> qDebug() << "Date:" << QDate::currentDate(); qDebug() << "Types:" << QString("String") << QChar('x') << QRect(0, 10, 50, 40); qDebug() << "Custom coordinate type:" << coordinate;</pre> <p>This constructs a QDebug object using the constructor that accepts a <a href="qtglobal.html#QtMsgType-enum">QtMsgType</a> value of <a href="qtglobal.html#QtMsgType-enum">QtDebugMsg</a>. Similarly, the <a href="qtglobal.html#qWarning">qWarning</a>(), <a href="qtglobal.html#qCritical">qCritical</a>() and <a href="qtglobal.html#qFatal">qFatal</a>() functions also return QDebug objects for the corresponding message types.</p> <p>The class also provides several constructors for other situations, including a constructor that accepts a <a href="qfile.html">QFile</a> or any other <a href="qiodevice.html">QIODevice</a> subclass that is used to write debugging information to files and other devices. The constructor that accepts a <a href="qstring.html">QString</a> is used to write to a string for display or serialization.</p> <a name="writing-custom-types-to-a-stream"></a> <h3>Writing Custom Types to a Stream</h3> <p>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:</p> <pre> QDebug operator<<(QDebug dbg, const Coordinate &c) { dbg.nospace() << "(" << c.x() << ", " << c.y() << ")"; return dbg.space(); }</pre> <p>This is described in the <a href="debug.html">Debugging Techniques</a> and <a href="custom-types.html#making-the-type-printable">Creating Custom Qt Types</a> documents.</p> <hr /> <h2>Member Function Documentation</h2> <a name="//apple_ref/cpp/instm/QDebug/QDebug"></a> <h3 class="fn"><a name="QDebugx"></a>QDebug::QDebug ( <a href="qiodevice.html">QIODevice</a> * <i>device</i> )</h3> <p>Constructs a debug stream that writes to the given <i>device</i>.</p> <h3 class="fn"><a name="QDebug-2"></a>QDebug::QDebug ( <a href="qstring.html">QString</a> * <i>string</i> )</h3> <p>Constructs a debug stream that writes to the given <i>string</i>.</p> <h3 class="fn"><a name="QDebug-3"></a>QDebug::QDebug ( <a href="qtglobal.html#QtMsgType-enum">QtMsgType</a> <i>type</i> )</h3> <p>Constructs a debug stream that writes to the handler for the message type specified by <i>type</i>.</p> <h3 class="fn"><a name="QDebug-4"></a>QDebug::QDebug ( const QDebug & <i>other</i> )</h3> <p>Constructs a copy of the <i>other</i> debug stream.</p> <a name="//apple_ref/cpp/instm/QDebug/~QDebug"></a> <h3 class="fn"><a name="dtor.QDebug"></a>QDebug::~QDebug ()</h3> <p>Flushes any pending data to be written and destroys the debug stream.</p> <a name="//apple_ref/cpp/instm/QDebug/maybeSpace"></a> <h3 class="fn"><a name="maybeSpace"></a>QDebug & QDebug::maybeSpace ()</h3> <p>Writes a space character to the debug stream, depending on the last character sent to the stream, and returns a reference to the stream.</p> <p>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.</p> <p>See also <a href="qdebug.html#space">space</a>() and <a href="qdebug.html#nospace">nospace</a>().</p> <a name="//apple_ref/cpp/instm/QDebug/nospace"></a> <h3 class="fn"><a name="nospace"></a>QDebug & QDebug::nospace ()</h3> <p>Clears the stream's internal flag that records whether the last character was a space and returns a reference to the stream.</p> <p>See also <a href="qdebug.html#space">space</a>() and <a href="qdebug.html#maybeSpace">maybeSpace</a>().</p> <a name="//apple_ref/cpp/instm/QDebug/space"></a> <h3 class="fn"><a name="space"></a>QDebug & QDebug::space ()</h3> <p>Writes a space character to the debug stream and returns a reference to the stream.</p> <p>The stream will record that the last character sent to the stream was a space.</p> <p>See also <a href="qdebug.html#nospace">nospace</a>() and <a href="qdebug.html#maybeSpace">maybeSpace</a>().</p> <a name="//apple_ref/cpp/instm/QDebug/operator<<"></a> <h3 class="fn"><a name="operator-lt-lt"></a>QDebug & QDebug::operator<< ( <a href="qchar.html">QChar</a> <i>t</i> )</h3> <p>Writes the character, <i>t</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-3"></a>QDebug & QDebug::operator<< ( bool <i>t</i> )</h3> <p>Writes the boolean value, <i>t</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-4"></a>QDebug & QDebug::operator<< ( char <i>t</i> )</h3> <p>Writes the character, <i>t</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-5"></a>QDebug & QDebug::operator<< ( signed short <i>i</i> )</h3> <p>Writes the signed short integer, <i>i</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-6"></a>QDebug & QDebug::operator<< ( unsigned short <i>i</i> )</h3> <p>Writes then unsigned short integer, <i>i</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-7"></a>QDebug & QDebug::operator<< ( signed int <i>i</i> )</h3> <p>Writes the signed integer, <i>i</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-8"></a>QDebug & QDebug::operator<< ( unsigned int <i>i</i> )</h3> <p>Writes then unsigned integer, <i>i</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-9"></a>QDebug & QDebug::operator<< ( signed long <i>l</i> )</h3> <p>Writes the signed long integer, <i>l</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-10"></a>QDebug & QDebug::operator<< ( unsigned long <i>l</i> )</h3> <p>Writes then unsigned long integer, <i>l</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-11"></a>QDebug & QDebug::operator<< ( <a href="qtglobal.html#qint64-typedef">qint64</a> <i>i</i> )</h3> <p>Writes the signed 64-bit integer, <i>i</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-12"></a>QDebug & QDebug::operator<< ( <a href="qtglobal.html#quint64-typedef">quint64</a> <i>i</i> )</h3> <p>Writes then unsigned 64-bit integer, <i>i</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-13"></a>QDebug & QDebug::operator<< ( float <i>f</i> )</h3> <p>Writes the 32-bit floating point number, <i>f</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-14"></a>QDebug & QDebug::operator<< ( double <i>f</i> )</h3> <p>Writes the 64-bit floating point number, <i>f</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-15"></a>QDebug & QDebug::operator<< ( const char * <i>s</i> )</h3> <p>Writes the '\0'-terminated string, <i>s</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-16"></a>QDebug & QDebug::operator<< ( const <a href="qstring.html">QString</a> & <i>s</i> )</h3> <p>Writes the string, <i>s</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-17"></a>QDebug & QDebug::operator<< ( const <a href="qstringref.html">QStringRef</a> & <i>s</i> )</h3> <p>Writes the string reference, <i>s</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-18"></a>QDebug & QDebug::operator<< ( const <a href="qlatin1string.html">QLatin1String</a> & <i>s</i> )</h3> <p>Writes the Latin1-encoded string, <i>s</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-19"></a>QDebug & QDebug::operator<< ( const <a href="qbytearray.html">QByteArray</a> & <i>b</i> )</h3> <p>Writes the byte array, <i>b</i>, to the stream and returns a reference to the stream.</p> <h3 class="fn"><a name="operator-lt-lt-20"></a>QDebug & QDebug::operator<< ( const void * <i>p</i> )</h3> <p>Writes a pointer, <i>p</i>, to the stream and returns a reference to the stream.</p> <a name="//apple_ref/cpp/instm/QDebug/operator="></a> <h3 class="fn"><a name="operator-eq"></a>QDebug & QDebug::operator= ( const QDebug & <i>other</i> )</h3> <p>Assigns the <i>other</i> debug stream to this stream and returns a reference to this stream.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="40%" align="left">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td> <td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="40%" align="right"><div align="right">Qt 4.6.3</div></td> </tr></table></div></address></body> </html>