久久久久久久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 * 用系統(tǒng)編碼編碼,可以用 QTextCodec::codecForLocale() 那么你應(yīng)該使用這個方法:


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);

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

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

相關(guān)文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數(shù)據(jù)?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環(huán): for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環(huán)?)
Reusing thread in loop c++(在循環(huán) C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環(huán)形?)
主站蜘蛛池模板: 精品欧美一区二区三区久久久小说 | 亚洲精久久久 | 狠狠干狠狠插 | h视频在线看 | 欧美日韩在线高清 | 欧美国产激情二区三区 | 麻豆av在线免费观看 | 国产成人99久久亚洲综合精品 | 成人性视频免费网站 | 91pao对白在线播放 | 国产精品视频一二三区 | 91在线看 | 久久免费视频在线 | 99精品网站 | 欧美韩一区二区 | 国产精品激情在线 | 日本精品视频 | 成人在线观看亚洲 | 日韩免费在线观看视频 | 天天艹 | 奇米四色在线观看 | aaa在线| 成人欧美一区二区三区在线观看 | 日本不卡在线观看 | 91文字幕巨乱亚洲香蕉 | 福利片一区二区 | 超碰成人免费 | 欧美日韩成人在线 | 9999精品视频 | 91精品国模一区二区三区 | 国产视频福利在线观看 | 国产一区二区视频免费在线观看 | www.亚洲 | 国产三级精品三级在线观看四季网 | 亚洲一区二区三区在线视频 | 99精品一区二区三区 | 国产电影一区二区在线观看 | 久久香蕉精品视频 | 在线观看日韩精品视频 | 日本一区二区不卡视频 | 免费观看av |