久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何將字符串更改為 QString?

How to change string into QString?(如何將字符串更改為 QString?)
本文介紹了如何將字符串更改為 QString?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

最基本的方法是什么?

推薦答案

如果你說的字符串是 std::string 你可以用這個方法:

If by string you mean std::string you can do it with this method:

QString QString::fromStdString(const std::string & str)

std::string str = "Hello world";
QString qstr = QString::fromStdString(str);

<小時>

如果你的字符串是 Ascii 編碼的 const char * 那么你可以使用這個方法:


If by string you mean Ascii encoded const char * then you can use this method:

QString QString::fromAscii(const char * str, int size = -1)

const char* str = "Hello world";
QString qstr = QString::fromAscii(str);

<小時>

如果你有 const char * 用系統編碼編碼,可以用 QTextCodec::codecForLocale() 那么你應該使用這個方法:


If you have const char * encoded with system encoding that can be read with QTextCodec::codecForLocale() then you should use this method:

QString QString::fromLocal8Bit(const char * str, int size = -1)

const char* str = "za?ó?? g??l? ja?ń";      // latin2 source file and system encoding
QString qstr = QString::fromLocal8Bit(str);

<小時>

如果你有 const char * 是 UTF8 編碼的,那么你需要使用這個方法:


If you have const char * that's UTF8 encoded then you'll need to use this method:

QString QString::fromUtf8(const char * str, int size = -1)

const char* str = read_raw("hello.txt"); // assuming hello.txt is UTF8 encoded, and read_raw() reads bytes from file into memory and returns pointer to the first byte as const char*
QString qstr = QString::fromUtf8(str);

<小時>

還有一個方法用于 const ushort * 包含 UTF16 編碼的字符串:


There's also method for const ushort * containing UTF16 encoded string:

QString QString::fromUtf16(const ushort * unicode, int size = -1)

const ushort* str = read_raw("hello.txt"); // assuming hello.txt is UTF16 encoded, and read_raw() reads bytes from file into memory and returns pointer to the first byte as const ushort*
QString qstr = QString::fromUtf16(str);

這篇關于如何將字符串更改為 QString?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 一区二区三区高清 | 日韩精品视频在线 | 夜夜爽99久久国产综合精品女不卡 | av久久| 亚洲天堂av一区 | 午夜视频导航 | 蜜桃视频成人 | 成人在线中文字幕 | 视频在线一区二区 | 亚洲一区在线日韩在线深爱 | 亚洲综合无码一区二区 | 国产粉嫩尤物极品99综合精品 | 亚洲最新在线视频 | 香蕉婷婷| 中文字幕亚洲视频 | 呦呦在线视频 | 久久视频免费看 | 日韩免费三级 | 国产日韩欧美一区二区 | 中文字幕第一页在线 | 天天干狠狠操 | 性高湖久久久久久久久 | 99视频在线播放 | 国产一区二区三区欧美 | 亚洲啪啪一区 | 国产精品一区久久久 | aa级毛片毛片免费观看久 | 久久精品com | 亚洲一区视频在线 | 欧美一级黄色片在线观看 | 欧美综合一区二区三区 | 亚洲综合色婷婷 | 亚洲午夜小视频 | 欧美成人视屏 | 国产精品久久精品 | 亚洲有码转帖 | 国产精品国产a级 | 国产伦精品一区二区三区四区视频 | 免费黄色在线观看 | 99精品国产一区二区三区 | 欧美在线一区二区三区 |