2024年11月26日 星期二

解決 qDebug 使用 % 符號顯示字串變成亂碼

qDebug()使用 %s 顯示字串

qDebug("key1: %s", qPrintable(jsonObject["key1"].toString()));

qPrintable() 是一個幫助函數,用來將 QString 轉換為 const char* 格式的 C 字串。這是因為 %s 需要傳遞 C 風格的字串(即 const char*)。

使用 % 符號進行數字格式化

qDebug("Age: %d", jsonObject["age"].toInt());


沒有留言:

張貼留言