分页: 1 / 1

qDebug() 打印出来的QString类型带引号解决方法

发表于 : 周五 5月 31, 2024 8:29 am
BG6RSH
问题1:输出无中文
  1. qDebug() << QString("hello") << "hello";
输出结果:
"hello" hello

解决方法1:
使用 qPrintable方法
  1. qDebug() << qPrintable(QString("hello")) << "hello";
问题二:当输出为有中文时时
解决方法:
// 测试
  1. qDebug() << qPrintable(QString("hello你好啊")) << "hello你好啊";
hello???e? hello你好啊
使用qPrintable会有乱码
解决方法2:qUtf8Printable
  1. qDebug() << qUtf8Printable(QString("hello你好啊")) << "hello你好啊";