Reputation: 904
How to convert easiest way in Qt?
int recordSize = 1000;
TCHAR* qRecord = new TCHAR[recordSize];
//here I get data form other function
//here I try to display
qString() << QString::fromWCharArray(qRecord,recordSize);//gives many ????
printf("%s",qRecord); // this work perfectly
I tried with wcstombs, formStdWString nad other but nothing seems to work. Thanks for any help
Upvotes: 5
Views: 8036
Reputation: 131
@kajojeq no, your second answer is not correct. because when the encoding is set to utf16(or even utf8 sometimes) the s variable only save one character. correct conversion is:
QString str = QString::fromWCharArray(qrecord)
Upvotes: 7