QDebug在开发过程当中使用得较多,整理了一些较少用却颇有用的知识。
QDebug &QDebug::nospace()
对比:函数
qDebug() << "Hello" << "world!"; qDebug().nospace() << "Hello" << "world!"; 输出: Hello world! Helloworld!
禁用在 QChar,QString 和 QByteArray内容周围自动插入引号字符。当开启引号字符禁用时,这些类型的打印将不带引号字符,也不会转义不可打印的字符。spa
QDebug &QDebug::noquote()
对比:code
qDebug() << QString("Hello world!"); qDebug().noquote() << QString("Hello world!"); 输出: "Hello world!" Hello world!
若是向函数传递格式字符串和参数列表,则其工做方式与C语言的printf()函数相似。格式应为Latin-1字符串。开发
qDebug(const char *message, ...)
如:字符串
qDebug("%s", "Hello world!");
项目文件(.pro)添加class
DEFINES+= QT_NO_DEBUG_OUTPUT