Qt QString转char[]数组 Qt QString转char[]数组 QString s1="1234456";char str[20]={0};strcpy(str,s1.toStdString().c_str(),strlen(s1.length()));Qt中 QString 转 char* Qt下面,字符串都用QString,确实给开发者提供了方便,想想VC里面定义的各种变量类型,而且函数参数类型五花八门,经常需要今年...
//QString to wchar_t: const wchar_t * encodedName = reinterpret_cast<const wchar_t *>(fileName.utf16()); //QString to char * (general case): const char * tmp = str.toUtf8().constData(); //wchar_t* to QString wchar_t szMsg[100] = {0}; _stprintf(szMsg,L"Connect [%s]...
char array[1024]QString str(array)只要数组最后一位是“\0”就行!...这样就行了
//QString to char * (general case): constchar * tmp = str.toUtf8().constData(); //wchar_t* to QString wchar_t szMsg[100] = {0}; _stprintf(szMsg,L"Connect [%s] failed!",ssid); QString str1= QString::fromWCharArray(szMsg); ...