QDebug Class Reference
[QtCore module]<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

该类为 debug 信息提供一个输出流
#include <QDebug>
公共函数
                            QDebug(QIODevice *device)
                            QDebug(QString *string)
QDebug(QtMsgType type)
QDebug(const QDebug&other)
~QDebug()
QDebug  &maybeSpace()
QDebug &nospace()
QDebug &operator<<(QChar t)
QDebug &operator<<(bool t)
QDebug &operator<<(signed short i)
QDebug &operator<<(unsigned short i)
QDebug &operator<<(signed int i)
QDebug &operator<<(unsigned int i)
QDebug &operator<<(qint64 i)
QDebug &operator<<(quint64 i)
QDebug &operator<<(float f)
QDebug &operator<<(double f)
QDebug &operator<<(const char *s)
QDebug &operator<<(const QString &s)
QDebug &operator<<(const QStringRef &s)
QDebug &operator<<(const QLatin1String &s)
QDebug &operator<<(const QByteArray&b)
QDebug &operator<<(const coid *p)
QDebug &operator=(const QDebug &other)

 

详细描述
当开发者需要为一个装置、文件、字符串或者控制台,写出调试和跟踪信息时,该类被使用。
基本应用
一般情况下,使用 qDebug() 就可以获得一个缺省的 QDebug 对象
qDebug()<<”Date:”<<QDate::currentDate();
qDebug()<<”Types:”<<QString(“QString(“String”)”<<QChar(‘x’)<<QRect(0,10,50,40));
qDebug()<<”Custom coordinate type:”<<coordinate;
这构造一个 QDebug 对象,它使用接受一个来自 QtDebugMsg QtMsgType 值的构造器。相同的, qWaring(),qCritical(),qFatal() 也返回 QDebug 对象为相应的消息类型。
这个类也提供一些构造器为其他的情况,包括一个构造器,它接受一个 QFile 或者任何 QIODevice 子类,他被用来写调试信息到文件和其他设备。这个构造器也接受一个 QString ,被用来写一个 string 为了显示或者序列。
写一般的类型到一个流
许多标准的类型能被写到 QDebug 对象,并且 Qt 提供支持位大多数 Qt 值类型。为了增加支持位一般的类型,你需要执行一个流动的操作。例如

 

这个被描述在 Debugging Techniques Creating Custom Qt Types 文件中
成员函数文件

QDebug::QDebug ( QIODevice * device )

构造一个 debug 流,它写到一个被给的设备

QDebug::QDebug ( QString * string )

构造一个 debug 流,他被写到一个被给的流。

QDebug::QDebug ( QtMsgType type )

构造一个 debug 流,他被写到一个句柄为特别的消息类型

QDebug::QDebug ( const QDebug & other )

构造一个其他 debug 流的拷贝

QDebug::~QDebug ()

析构函数

QDebug & QDebug::maybeSpace ()

写一个空格字符到 debug 流,依靠最后一个被送到流中的字符,返回一个流的参考。
如果最后的字符是一个空格,这个函数写一个空格到流中;否则没有字符被写到流中。
也看 space ()和 nospace ()

QDebug & QDebug::nospace ()

清除流的内部的记录是否最后一个字符时空格的标志,返回一个流的参考。
也看 space ()和 maybeSpace ()

QDebug & QDebug::space ()

写一个空格字符到 debug 流,并且返回一个流的参考。这个流将记录最后一个被发送到流中的字符为空格。
也看 nospace ()和 maybespace ()

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

写一个 Q 字符 t 到流,返回一个流的参考

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

写一个 bool t 到流中,返回一个流的参考

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

写一个字符 t 到流,返回一个流的参考

QDebug & QDebug::operator<< ( signed short i )

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

QDebug & QDebug::operator<< ( signed int i )

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

QDebug & QDebug::operator<< ( signed long l )

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

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

写一个有符号的 64 比特整数 i 到流中,返回一个流的参考

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

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

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

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

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

QDebug & QDebug::operator<< ( const QStringRef & s )

写一个 string 参考 s 到流中,返回一个流的参考

QDebug & QDebug::operator<< ( const QLatin1String & s )

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

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

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