QString Str ("Hello");
QString str = "Hello";
static const Qchar Data[4] = {0x0055, 0x006e, 0x10e3, 0x03a3};
QString Str (data, 4);
QString str;
Str.resize (4);
Str[0] = Qchar (' U ');
STR[1] = Qchar (' n ');
STR[2] = Qchar (0X10E3);
STR[3] = Qchar (0X03A3);
QString str;
str.sprintf ("%s%.3f", "float", 3.1415926);
Str result is "float 3.14"
QString str;
Str.setnum (10); str = "10"
Str.setnum (10, 16); str = "a"
Str.setnum (10.12345); str = "10.12345"
QString i; Current file ' s number
QString Total; Number of files to process
QString FileName; Current file ' s name
QString status = QString ("Processing file%1 of% 2:%3")
. Arg (i). Arg (total). Arg (fileName);
Reference: http://blog.csdn.net/xgbing/article/details/7770854
------------------------------------------------------------------
1) Char * initialization
QString str = "Hello";
QString converts the const char * data into Unicode using the Fromascii () function.
2) qchar[] array initialization
CPP Code
- Static const Qchar Data[4] = {0x0055, 0x006e, 0x10e3, 0x03a3};
- QString Str (data, 4);
You can do that.
CPP Code
- Qregexp pattern;
- Static const Qchar unicode[] = {0x005a, 0x007F, 0X00A4, 0x0060,
- 0x1009, 0x0020, 0x0020};
- int size = sizeof (Unicode)/ sizeof (QCHAR);
- QString str = qstring::fromrawdata (Unicode, size);
3) can also be initialized with the risize () function and each Qchar character
CPP Code
- QString str;
- Str.resize (4);
- Str[0] = Qchar (' U ');
- STR[1] = Qchar (' n ');
- STR[2] = Qchar (0X10E3);
- STR[3] = Qchar (0X03A3);
Each character read through the at () function
CPP Code
- QString str;
- For (int i = 0; i < str.size (); ++i) {
- if (str.at (i) >= Qchar (' a ') && str.at (i) <= Qchar (' F '))
- Qdebug () << "Found character in range [a-f]";
- }
Reference: http://qimo601.iteye.com/blog/1432867
Uncommon usage of qstring