本文介紹了將 std::string 轉換為 QString的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個 std::string content
,我知道它包含 UTF-8 數據.我想將其轉換為 QString
.如何避免 Qt 中的 from-ASCII 轉換?
I've got an std::string content
that I know contains UTF-8 data. I want to convert it to a QString
. How do I do that, avoiding the from-ASCII conversion in Qt?
推薦答案
有一個 QString
函數叫做 fromUtf8
需要一個 const char*
:
There's a QString
function called fromUtf8
that takes a const char*
:
QString str = QString::fromUtf8(content.c_str());
這篇關于將 std::string 轉換為 QString的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!