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