您的位置:首页 > Web前端

菜鸟玩qt(11)--- 翻译QDebug Class Reference

2010-01-22 19:53 477 查看


[title2]QDebugClassReference
[QtCoremodule][/title2]

该类为debug信息提供一个输出流
#include<QDebug>
公共函数
QDebug(QIODevice*device)
QDebug(QString*string)
QDebug(QtMsgTypetype)
QDebug(constQDebug&other)
~QDebug()
QDebug&maybeSpace()
QDebug&nospace()
QDebug&operator<<(QChart)
QDebug&operator<<(boolt)
QDebug&operator<<(signedshorti)
QDebug&operator<<(unsignedshorti)
QDebug&operator<<(signedinti)
QDebug&operator<<(unsignedinti)
QDebug&operator<<(qint64i)
QDebug&operator<<(quint64i)
QDebug&operator<<(floatf)
QDebug&operator<<(doublef)
QDebug&operator<<(constchar*s)
QDebug&operator<<(constQString&s)
QDebug&operator<<(constQStringRef&s)
QDebug&operator<<(constQLatin1String&s)
QDebug&operator<<(constQByteArray&b)
QDebug&operator<<(constcoid*p)
QDebug&operator=(constQDebug&other)

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

这个被描述在DebuggingTechniques和CreatingCustomQtTypes文件中
成员函数文件

QDebug::QDebug(QIODevice*device)

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

QDebug::QDebug(QString*string)

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

QDebug::QDebug(QtMsgTypetype)

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

QDebug::QDebug(constQDebug&other)

构造一个其他debug流的拷贝

QDebug::~QDebug()

析构函数

QDebug&QDebug::maybeSpace()

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

QDebug&QDebug::nospace()

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

QDebug&QDebug::space()

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

QDebug&QDebug::operator<<(QChart)

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

QDebug&QDebug::operator<<(boolt)

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

QDebug&QDebug::operator<<(chart)

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

QDebug&QDebug::operator<<(signedshorti)

QDebug&QDebug::operator<<(unsignedshorti)

QDebug&QDebug::operator<<(signedinti)

QDebug&QDebug::operator<<(unsignedinti)

QDebug&QDebug::operator<<(signedlongl)

QDebug&QDebug::operator<<(unsignedlongl)

QDebug&QDebug::operator<<(qint64i)

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

QDebug&QDebug::operator<<(quint64i)

QDebug&QDebug::operator<<(floatf)

QDebug&QDebug::operator<<(doublef)

QDebug&QDebug::operator<<(constchar*s)

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

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

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

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

QDebug&QDebug::operator<<(constQByteArray&b)

QDebug&QDebug::operator<<(constvoid*p)

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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: