關閉自動插入空格
QDebug &QDebug::nospace()
範例:
qDebug() << "Hello" << "world!";
qDebug().nospace() << "Hello" << "world!";
輸出:
Hello world!
Helloworld!
關閉引號字符
禁用在 QChar,QString 和 QByteArray內容周圍自動插入引號字符。當開啓引號字符禁用時,這些類型的打印將不帶引號字符,也不會轉義不可打印的字符。
QDebug &QDebug::noquote()
範例:
qDebug() << QString("Hello world!");
qDebug().noquote() << QString("Hello world!");
輸出:
"Hello world!"
Hello world!
不用導入頭文件 使用 qDebug
如果向函數傳遞格式字符串和參數列表,則其工作方式與C語言的printf()函數類似。格式應爲Latin-1字符串
qDebug(const char *message, ...)
qDebug("%s", "Hello world!");
屏蔽qDebug打印
項目文件(.pro)添加
DEFINES+= QT_NO_DEBUG_OUTPUT