qDebug() 打印出来的QString类型带引号解决方法
发表于 : 周五 5月 31, 2024 8:29 am
问题1:输出无中文
输出结果:
"hello" hello
解决方法1:
使用 qPrintable方法
问题二:当输出为有中文时时
解决方法:
// 测试
hello???e? hello你好啊
使用qPrintable会有乱码
解决方法2:qUtf8Printable
Code: [全选] [Expand/Collapse]
- qDebug() << QString("hello") << "hello";
"hello" hello
解决方法1:
使用 qPrintable方法
Code: [全选] [Expand/Collapse]
- qDebug() << qPrintable(QString("hello")) << "hello";
解决方法:
// 测试
Code: [全选] [Expand/Collapse]
- qDebug() << qPrintable(QString("hello你好啊")) << "hello你好啊";
使用qPrintable会有乱码
解决方法2:qUtf8Printable
Code: [全选] [Expand/Collapse]
- qDebug() << qUtf8Printable(QString("hello你好啊")) << "hello你好啊";