Qt开发 — QDebug 使用小结

关闭自动插入空格
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

你可能感兴趣的:(Qt,嵌入式开发,QDebug)