Http://blog.csdn.net/ymc0329/article/details/7284514
Convert int to qstring
Int M = 1;
Qstring B;
B = qstring: Number (m)
Convert qstring to int
Qstring A = "1111"
Int B;
B = A. toint ()
Char to qstring
Char A = 'B ';
Qstring STR;
STR = qstring ();
Convert qstring to Char
Qstring STR = "QQ ";
Char * Ch;
Ch = Str. tolatin1.data ();
Conversion between char * and const char *
Char * character = "TT ";
Const char * CH2 = "QQ ";
CH2 = warning; // No error is reported, but a warning is reported.
Substring = (char *) CH2;
Convert qbytearray to char *
Char * Ch; // do not define it as CH [N];
Qbytearray byte;
Ch = byte. Data ();
Char * To qbytearray
Char * Ch;
Qbytearray byte;
Byte = qbytearray (CH );
Convert qstring to qbytearray
Qbytearray byte;
Qstring string;
Byte = string. toascii ();
Convert qbytearray to qstring
Qbytearray byte;
Qstring string;
String = qstring (byte );
Example:
Qdebug () <"QQ ";
Qdebug () <tr ("TT ");
Qdebug () <ch; (CH is char type)
Qdebug () <tr (CH );
Qdebug () <bytearray; (bytearray is of the qbytearray type)
Qdebug () <tr (bytearray );
Qdebug () <STR; (STR is of the qstring type)
However, qdebug () <tr (STR); is not acceptable. To use the tr () function to output qstring-type characters, you must:
Qdebug () <tr (Str. tolatin1 );
Qstring string
Qstring s2q (const string & S)
{
Return qstring (qstring: fromlocal8bit (S. c_str ()));
}
String q2s (const qstring & S)
{
Return string (const char *) S. tolocal8bit ());
}
Conversion between qstring, Int, Char, and qbytearray in QT