在介绍内容之前,先说明一下开发环境,如下图:
Qt版本:Qt5.3.2;
Qt开发工具:Qt Creater 3.2.1;
Qt构建工具:Desktop Qt 5.3 MinGW 32bit;
Qt开发平台:Windows 7 64bit。
之前,各个独立主题的博客链接如下。
01). 0022:Qt常用类 - QString(01,QString的编码方式和初始化)
02). 0023:Qt常用类 - QString(02,增加)
03). 0024:Qt常用类 - QString(03,删除)
04). 0025:Qt常用类 - QString(04,修改)
05). 0026:Qt常用类 - QString(05,查询)
06). 0027:Qt常用类 - QString(06,遍历)
07). 0028:Qt常用类 - QString(07,子字符串)
08). 0029:Qt常用类 - QString(08,格式化)
09). 0030:Qt常用类 - QString(09,比较)
10). 0031:Qt常用类 - QString(10,转换)
下面,将QString的接口分为初始化、增加、删除、修改、查询、遍历、子字符串、格式化、比较和转换共10类进行汇总,形成一份完成的内容。
在介绍QString的使用之前,先介绍一下QString的编码方式。QString采用Unicode编码方式,即:每一个字符用两个字节来表示,当然这里的每一个字符不是传统C字符串中的ASCII字符,它涵盖了更多的字符,比如:中文、俄文、日文等等。
Unicode是当前国际标准的编码字符集,支持大多数的写入系统,它是US-ASCII (ANSI X3.4-1986)字符集和Latin-1 (ISO 8859-1)字符集的超集。
下面介绍初始化接口的使用例程。
qDebug("--- string: 初始化 ---");
/*
* QString()
* QString(const QChar * unicode, int size = -1)
* QString(QChar ch)
* QString(int size, QChar ch)
* QString(const QString & other)
* QString(const char * str)
* operator=(const char * str)
*/
//QString
QString str1;
qDebug("str1 is empty? %s", str1.isEmpty() ? "yes" : "no");
//QString(const QChar * unicode, int size = -1)
QChar *pCharNull = NULL;
QChar pCharNormal[10] = { '1', '2', '3', '4', '5', NASCII_UC("一"), NASCII_UC("二"), NASCII_UC("三"), NASCII_UC("四"), NASCII_UC("五") };
QChar pCharNullTerminated[11] = { '1', '2', '3', '4', '5', NASCII_UC("一"), NASCII_UC("二"), NASCII_UC("三"), NASCII_UC("四"), NASCII_UC("五"), 0 };
QString str2(pCharNull); //If unicode is 0, a null string is constructed.
QString str3(pCharNormal, 10);
QString str4(pCharNullTerminated); //If size is negative, unicode is assumed to point to
//a nul-terminated array and its length is determined
//dynamically. The terminating nul-character is not
//considered part of the string.
qDebug("str2 is empty? %s", str2.isEmpty() ? "yes" : "no");
qDebug("str3 = %s, length = %d", qPrintableU8(str3), str3.length());
qDebug("str4 = %s, length = %d", qPrintableU8(str4), str4.length());
QMessageBox::question(this, "问题 - 标题", str4, "是", "否", "忽略", 0, 2);
//QString(QChar ch)
QString str5(pCharNormal[5]);
qDebug("str5 = %s, unicode = 0x%04X", qPrintableU8(str5), NASCII_UC(str5));
//QString(int size, QChar ch)
QString str6(10, pCharNormal[9]);
qDebug("str6 = %s, length = %d", qPrintableU8(str6), str6.length());
//QString(const QString &string)
//QString(const char * str)
//operator=(const char * str)
QString str7 = "12345一二三四五";
QString str8("12345一二三四五");
QString str9(str7);
qDebug("str7 = %s, length = %d", qPrintableU8(str7), str7.length());
qDebug("str8 = %s, length = %d", qPrintableU8(str8), str8.length());
qDebug("str9 = %s, length = %d", qPrintableU8(str9), str9.length());
在学习过程中,可以将上述代码放到一个按钮的响应函数中,以调试方式运行,就可以在Qt Creater中的应用程序输出窗口看到输出结果了。
下面是增加部分的示例代码。
/*
* append(const QString &str)
* append(const QChar *str, int len)
* append(QChar ch)
* prepend(const QString &str)
* prepend(QChar ch)
* push_back(const QString &str)
* push_back(QChar ch)
* push_front(const QString &str)
* push_front(QChar ch)
* insert(int position, const QString &str)
* insert(int position, const QChar *unicode, int size)
* insert(int position, QChar ch)
* operator+=(const QString &str)
* operator+=(QChar ch)
*/
//append(const QString &str)
QString strTemp = "12345一二三四五";
str1.append(strTemp);
qDebug("- 01 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//append(const QChar *str, int len)
QChar *pCharNull = NULL;
str1.clear();
str1.append(pCharNull, 10);
qDebug("- 02 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
QChar pCharNormal[10] = { '1', '2', '3', '4', '5', NASCII_UC("一"), NASCII_UC("二"), NASCII_UC("三"), NASCII_UC("四"), NASCII_UC("五") };
str1.clear();
str1.append(pCharNormal, 10);
qDebug("- 03 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//append(QChar ch)
QChar chTemp = '1';
str1.clear();
str1.append(chTemp);
qDebug("- 04 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//prepend(const QString &str)
str1.clear();
str1.prepend(strTemp);
qDebug("- 05 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//prepend(QChar ch)
str1.clear();
str1.prepend(chTemp);
qDebug("- 06 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//push_back(const QString &str)
str1.clear();
str1.push_back(strTemp);
qDebug("- 07 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//push_back(QChar ch)
str1.clear();
str1.push_back(chTemp);
qDebug("- 08 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//push_front(const QString &str)
str1.clear();
str1.push_front(strTemp);
qDebug("- 09 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//push_front(QChar ch)
str1.clear();
str1.push_front(chTemp);
qDebug("- 10 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//insert(int position, const QString &str)
str1.clear();
str1.insert(0, strTemp);
qDebug("- 11 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//insert(int position, const QChar *unicode, int size)
str1.clear();
str1.insert(0, pCharNormal, 10);
qDebug("- 12 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//insert(int position, QChar ch)
str1.clear();
str1.insert(0, chTemp);
qDebug("- 13 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//operator+=(const QString &str)
str1.clear();
str1 += strTemp;
qDebug("- 14 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//operator+=(QChar ch)
str1.clear();
str1 += chTemp;
qDebug("- 15 -: str1 = %s, length = %d", qPrintableU8(str1), str1.length());
在学习过程中,可以将上述代码放到一个按钮的响应函数中,以调试方式运行,就可以在Qt Creater中的应用程序输出窗口看到输出结果了。
下面是删除部分的示例代码。
QString str1;
qDebug("str1 is empty? %s", str1.isEmpty() ? "yes" : "no");
/*
* clear()
* chop(int n)
* remove(int position, int n)
* remove(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive)
* remove(const QString &str, Qt::caseSensitivity cs = Qt::CaseSensitive)
*/
//clear()
QString str2 = "12345一二三四五";
str2.clear();
qDebug("str2 is empty? %s", str2.isEmpty() ? "yes" : "no");
//chop(int n)
QString str3 = "12345一二三四五";
str3.chop(5);
qDebug("str3 = %s, length = %d", qPrintableU8(str3), str3.length());
str3.chop(10);
qDebug("str3 is empty? %s", str3.isEmpty() ? "yes" : "no");
//remove(int position, int n)
QString str4 = "12345一二三四五";
str4.remove(10, 10);
qDebug("position beyond the end, str4 = %s, length = %d", qPrintableU8(str4), str4.length());
str4.remove(5, 5);
qDebug("str4 = %s, length = %d", qPrintableU8(str4), str4.length());
str4.remove(0, 10);
qDebug("position +n beyond the end, str4 is empty? %s", str4.isEmpty() ? "yes" : "no");
//remove(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive)
QString str5 = "121212aAaAaA一二一二一二";
str5.remove(QChar('a'), Qt::CaseSensitive);
qDebug("Qt::CaseSensitive, str5 = %s, length = %d", qPrintableU8(str5), str5.length());
str5 = "121212aAaAaA一二一二一二";
str5.remove(QChar('a'), Qt::CaseInsensitive);
qDebug("Qt::CaseInsensitive, str5 = %s, length = %d", qPrintableU8(str5), str5.length());
str5 = "121212aAaAaA一二一二一二";
str5.remove(QChar(NASCII_UC("二")), Qt::CaseInsensitive);
qDebug("remove 汉字, str5 = %s, length = %d", qPrintableU8(str5), str5.length());
//remove(const QString &str, Qt::caseSensitivity cs = Qt::CaseSensitive)
QString str6 = "121212aAaAaA一二一二一二";
str6.remove("aaaaaa", Qt::CaseSensitive);
qDebug("Qt::CaseSensitive, str6 = %s, length = %d", qPrintableU8(str6), str6.length());
str6 = "121212aAaAaA一二一二一二";
str6.remove("aaaaaa", Qt::CaseInsensitive);
qDebug("Qt::CaseInsensitive, str6 = %s, length = %d", qPrintableU8(str6), str6.length());
str6 = "121212aAaAaA一二一二一二";
str6.remove("aaaaaa一二一二一二", Qt::CaseInsensitive);
qDebug("remove 汉字, str6 = %s, length = %d", qPrintableU8(str6), str6.length());
在学习过程中,可以将上述代码放到一个按钮的响应函数中,以调试方式运行,就可以在Qt Creater中的应用程序输出窗口看到输出结果了。
下面是修改部分的示例代码。
/*
* fill(QChar ch, int size = -1)
* replace(int position, int n, const QString &after)
* replace(int position, int n, const QChar *unicode, int size)
* replace(int position, int n, QChar after)
* replace(const QString &before, const QString &after, Qt::CaseSensitivity cs)
* replace(QChar ch, const QString &after, Qt::CaseSensitivity cs)
* replace(QChar before, QChar after, Qt::CaseSensitivity)
* truncate(int position)
* trimmed()
* operator+=(const QString &other)
* operator+=(QChar ch)
*/
//fill(QChar ch, int size = -1)
QString str1 = "12345一二三四五";
str1.fill(QChar('8'));
qDebug("fill all, str1 = %s, length = %d", qPrintableU8(str1), str1.length());
str1.fill(QChar('7'), 5);
qDebug("fill resize, str1 = %s, length = %d", qPrintableU8(str1), str1.length());
//replace(int position, int n, const QString &after)
QString str2 = "12345一二三四五";
str2.replace(5, 10, "67890六七八九零");
qDebug("str2 = %s, length = %d", qPrintableU8(str2), str2.length());
//replace(int position, int n, const QChar *unicode, int size)
QString str3 = "12345一二三四五";
QChar pCharNormal[10] = { '1', '2', '3', '4', '5', NASCII_UC("一"), NASCII_UC("二"), NASCII_UC("三"), NASCII_UC("四"), NASCII_UC("五") };
str3.replace(5, 10, pCharNormal, 5);
qDebug("str3 = %s, length = %d", qPrintableU8(str3), str3.length());
//replace(int position, int n, QChar after)
QString str4 = "12345一二三四五";
str4.replace(5, 10, QChar('6'));
qDebug("str4 = %s, length = %d", qPrintableU8(str4), str4.length());
//replace(const QString &before, const QString &after, Qt::CaseSensitivity cs)
QString str5 = "12345一二三四五";
str5.replace("一二三四五", "67890");
qDebug("str5 = %s, length = %d", qPrintableU8(str5), str5.length());
//replace(QChar ch, const QString &after, Qt::CaseSensitivity cs)
QString str6 = "12345一二三四五";
str6.replace(QChar('5'), "567890");
qDebug("str6 = %s, length = %d", qPrintableU8(str6), str6.length());
//replace(QChar before, QChar after, Qt::CaseSensitivity)
QString str7 = "12345一二三四五";
str7.replace(QChar('5'), QChar('6'));
qDebug("str7 = %s, length = %d", qPrintableU8(str7), str7.length());
//truncate(int position)
QString str8 = "12345一二三四五";
str8.truncate(5);
qDebug("str8 = %s, length = %d", qPrintableU8(str8), str8.length());
//trimmed()
QString str9 = "12345 一二三四五 ";
str9.trimmed();
qDebug("str9 = %s, length = %d", qPrintableU8(str9), str9.length());
//operator+=(const QString &other)
QString str10 = "12345一二三四五";
str10 += "67890六七八九零";
qDebug("str10 = %s, length = %d", qPrintableU8(str10), str10.length());
//operator+=(QChar ch)
QString str11 = "12345一二三四五";
str11 += QChar('6');
qDebug("str11 = %s, length = %d", qPrintableU8(str11), str11.length());
在学习过程中,可以将上述代码放到一个按钮的响应函数中,以调试方式运行,就可以在Qt Creater中的应用程序输出窗口看到输出结果了。
下面是查询部分的示例代码。
/*
* contains(const QString &str, Qt::CaseSensitivity cs)
* contains(QChar ch, Qt::CaseSensitivity cs)
* endsWith(const QString &s, Qt::CaseSensitivity cs)
* endsWith(QChar c, Qt::CaseSensitivity cs)
* indexOf(const QString &str, int from, Qt::CaseSensitivity cs)
* indexOf(QChar ch, int from, Qt::CaseSensitivity cs)
* lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs)
* lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs)
* startsWith(const QString &s, Qt::CaseSensitivity cs)
* startsWith(QChar ch, Qt::CaseSensitivity cs)
*/
//contains(const QString &str, Qt::CaseSensitivity cs)
QString strQuery = "abcdeABCDE一二三四五";
qDebug("strQuery.contains(\"abcdE\") = %d.", strQuery.contains("abcdE"));
//contains(QChar ch, Qt::CaseSensitivity cs)
qDebug("strQuery.contains(QChar('e')) = %d.", strQuery.contains(QChar('e')));
//endsWith(const QString &s, Qt::CaseSensitivity cs)
qDebug("strQuery.endsWith(\"一二三四五\") = %d.", strQuery.endsWith("一二三四五"));
//endsWith(QChar c, Qt::CaseSensitivity cs)
qDebug("strQuery.endsWith(QChar('e')) = %d.", strQuery.endsWith(QChar('e')));
//indexOf(const QString &str, int from, Qt::CaseSensitivity cs)
qDebug("strQuery.indexOf(\"一二三四五\") = %d.", strQuery.indexOf("一二三四五"));
//indexOf(QChar ch, int from, Qt::CaseSensitivity cs)
qDebug("strQuery.indexOf(QChar('e')) = %d.", strQuery.indexOf(QChar('e')));
//lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs)
qDebug("strQuery.lastIndexOf(\"一二三四五\") = %d.", strQuery.lastIndexOf("一二三四五"));
//lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs)
qDebug("strQuery.lastIndexOf(QChar('e')) = %d.", strQuery.lastIndexOf(QChar('e')));
//startsWith(const QString &s, Qt::CaseSensitivity cs)
qDebug("strQuery.startsWith(\"abcde\") = %d.", strQuery.startsWith("abcde"));
//startsWith(QChar ch, Qt::CaseSensitivity cs)
qDebug("strQuery.startsWith(QChar('e')) = %d.", strQuery.startsWith(QChar('e')));
在学习过程中,可以将上述代码放到一个按钮的响应函数中,以调试方式运行,就可以在Qt Creater中的应用程序输出窗口看到输出结果了。
下面是遍历部分的示例代码。
/*
* cbegin()
* cend()
* const QChar at(int position) const
* QCharRef operator[](int position)
* const QChar operator[](int position) const
*/
//cbegin()
//cend()
QString::const_iterator cit = NULL;
QString str1 = "12345一二三四五";
QString strTemp;
for (cit=str1.cbegin(); cit
在学习过程中,可以将上述代码放到一个按钮的响应函数中,以调试方式运行,就可以在Qt Creater中的应用程序输出窗口看到输出结果了。
下面是子字符串部分的示例代码。
/*
* left(int n)
* mid(int position, int n)
* right(int n)
* split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs)
* split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs)
*/
//left(int n)
//mid(int position, int n)
//right(int n)
QString str1 = "12345一二三四五";
qDebug("str1.left(5) = %s, str1.mid(4, 2) = %s, str1.right(5) = %s.",
qPrintableU8(str1.left(5)), qPrintableU8(str1.mid(4, 2)), qPrintableU8(str1.right(5)));
//split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs)
QString str2 = " 1 , 2 , 3 , 4 , 5 ,, 一 , 二 , 三 , 四 , 五 ";
QStringList list2 = str2.split(",", QString::SkipEmptyParts);
QStringList::const_iterator cit = NULL;
int index = 0;
for (cit=list2.cbegin(); cit
在学习过程中,可以将上述代码放到一个按钮的响应函数中,以调试方式运行,就可以在Qt Creater中的应用程序输出窗口看到输出结果了。
下面是格式化部分的示例代码。
char ch = -1;
uchar uch = 1;
short sh = -2;
ushort ush = 2;
int n = -3;
uint un = 3;
long l = -4;
ulong ul = 4;
qlonglong ql = -5;
qulonglong qul = 5;
float f = -6.0f;
double db = 7.0f;
char cch = 'a';
QChar qch('b');
QString str = "123";
QString strFormat = QString(
" ch = %1, uch = %2\n\
sh = %3, ush = %4\n\
n = %5, un = %6\n\
l = %7, ul = %8\n\
ql = %9, qul = %10\n\
f = %11, db = %12\n\
cch = %13, qch = %14\n\
str = %15").
arg((short)ch).arg((ushort)uch).
arg(sh).arg(ush).
arg(n).arg(un).
arg(l).arg(ul).
arg(ql).arg(qul).
arg(f).arg(db).
arg(cch).arg(qch).
arg(str);
qDebug("strFormat = \n%s", qPrintableU8(strFormat));
strFormat = QString(
" ch = 0x%1, uch = 0x%2\n\
sh = 0x%3, ush = 0x%4\n\
n = 0x%5, un = 0x%6\n\
l = 0x%7, ul = 0x%8\n\
ql = 0x%9, qul = 0x%10\n\
f = %11, db = %12\n\
cch = %13, qch = %14\n\
str = %15").
arg((short)ch, 8, STR_BASE(16), QChar('0')).arg((ushort)uch, 8, STR_BASE(16), QChar('0')).
arg(sh, 8, STR_BASE(16), QChar('0')).arg(ush, 8, STR_BASE(16), QChar('0')).
arg(n, 8, STR_BASE(16), QChar('0')).arg(un, 8, STR_BASE(16), QChar('0')).
arg(l, 8, STR_BASE(16), QChar('0')).arg(ul, 8, STR_BASE(16), QChar('0')).
arg(ql, 8, STR_BASE(16), QChar('0')).arg(qul, 8, STR_BASE(16), QChar('0')).
arg((double)f, 0, STR_AF('f'), STR_AP(6), QChar('0')).arg(db, 0, STR_AF('f'), STR_AP(15), QChar('0')).
arg(cch, 18, QChar(' ')).arg(qch, 8, QChar(' ')).
arg(str);
qDebug("strFormat = \n%s", qPrintableU8(strFormat));
strFormat = QString(
" ch = 0x%1, uch = 0x%2\n\
sh = 0x%3, ush = 0x%4\n\
n = 0x%5, un = 0x%6\n\
l = 0x%7, ul = 0x%8\n\
ql = 0x%9, qul = 0x%10\n\
f = %11, db = %12\n\
cch = %13, qch = %14\n\
str = %15").
arg((unsigned int)ch, 8, STR_BASE(16), QChar('0')).arg((ushort)uch, 8, STR_BASE(16), QChar('0')).
arg((unsigned int)sh, 8, STR_BASE(16), QChar('0')).arg(ush, 8, STR_BASE(16), QChar('0')).
arg((unsigned int)n, 8, STR_BASE(16), QChar('0')).arg(un, 8, STR_BASE(16), QChar('0')).
arg((unsigned int)l, 8, STR_BASE(16), QChar('0')).arg(ul, 8, STR_BASE(16), QChar('0')).
arg((unsigned int)ql, 8, STR_BASE(16), QChar('0')).arg(qul, 8, STR_BASE(16), QChar('0')).
arg((double)f, 0, STR_AF('f'), STR_AP(6), QChar('0')).arg(db, 0, STR_AF('f'), STR_AP(15), QChar('0')).
arg(cch, 18, QChar(' ')).arg(qch, 8, QChar(' ')).
arg(str);
qDebug("strFormat = \n%s", qPrintableU8(strFormat));
在学习过程中,可以将上述代码放到一个按钮的响应函数中,以调试方式运行,就可以在Qt Creater中的应用程序输出窗口看到输出结果了。
下面是比较部分的示例代码。
/*
* compare(const QString &other, Qt::CaseSensitivity cs)
* localeAwareCompare(const QString &other)
* operator==(const char *other)
* operator<(const char *other)
* operator<=(const char *other)
* operator>(const char *other)
* operator>=(const char *other)
*/
//compare(const QString &other, Qt::CaseSensitivity cs)
QString strComp = "12345abcde一二三四五";
qDebug("compare: result = %d.", strComp.compare("12345abcde一二三四五"));
//localeAwareCompare(const QString &other)
qDebug("localeAwareCompare: result = %d.", strComp.localeAwareCompare("23456"));
//operator==(const char *other)
qDebug("==: result = %d.", strComp == "23456abcde一二三四五");
//operator<(const char *other)
qDebug("<: result = %d.", strComp < "23456abcde一二三四五");
//operator<=(const char *other)
qDebug("<=: result = %d.", strComp <= "12345abcde一二三四五");
//operator>(const char *other)
qDebug(">: result = %d.", strComp > "23456abcde一二三四五");
//operator>=(const char *other)
qDebug(">=: result = %d.", strComp >= "23456abcde一二三四五");
在学习过程中,可以将上述代码放到一个按钮的响应函数中,以调试方式运行,就可以在Qt Creater中的应用程序输出窗口看到输出结果了。
下面是转换部分的示例代码。
/*
* --- 数字转换 ---
* QString & setNum(int n, int base = 10)
* QString & setNum(uint n, int base = 10)
* QString & setNum(long n, int base = 10)
* QString & setNum(ulong n, int base = 10)
* QString & setNum(qlonglong n, int base = 10)
* QString & setNum(qulonglong n, int base = 10)
* QString & setNum(short n, int base = 10)
* QString & setNum(ushort n, int base = 10)
* QString & setNum(double n, char format = 'g', int precision = 6)
* QString & setNum(float n, char format = 'g', int precision = 6)
* short toShort(bool * ok = 0, int base = 10) const
* int toInt(bool * ok = 0, int base = 10) const
* long toLong(bool * ok = 0, int base = 10) const
* qlonglong toLongLong(bool * ok = 0, int base = 10) const
* ushort toUShort(bool * ok = 0, int base = 10) const
* uint toUInt(bool * ok = 0, int base = 10) const
* ulong toULong(bool * ok = 0, int base = 10) const
* qulonglong toULongLong(bool * ok = 0, int base = 10) const
* float toFloat(bool * ok = 0) const
* double toDouble(bool * ok = 0) const
* QString QString::::number(long n, int base = 10)
* QString QString::::number(double n, char format = 'g', int precision = 6)
* QString QString::::number(ulong n, int base = 10)
* QString QString::::number(int n, int base = 10)
* QString QString::::number(uint n, int base = 10)
* QString QString::::number(qlonglong n, int base = 10)
* QString QString::number(qulonglong n, int base = 10)
*
* --- 编码转换 ---
* QString & setRawData(const QChar * unicode, int size)
* QString & setUnicode(const QChar * unicode, int size)
* QString & setUtf16(const ushort * unicode, int size)
* QByteArray toUtf8() const
* QVector toUcs4() const
* std::string toStdString() const
* std::wstring toStdWString() const
* int toWCharArray(wchar_t * array) const
* const QChar * unicode() const
* const ushort * utf16() const
* QString QString::fromRawData(const QChar * unicode, int size)
* QString QString::fromStdString(const std::string & str)
* QString QString::fromStdWString(const std::wstring & str)
* QString QString::fromUcs4(const uint * unicode, int size = -1)
* QString QString::fromUtf8(const char * str, int size = -1)
* QString QString::fromUtf8(const QByteArray & str)
* QString QString::fromUtf16(const ushort * unicode, int size = -1)
* QString QString::fromWCharArray(const wchar_t * string, int size = -1)
*
* --- 大小写转换 ---
* QString toLower() const
* QString toUpper() const
*/
//由于看函数名称,基本就知道怎么用了,所以不写实例代码了...