Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert LPTSTR to QString

Tags:

qt

qt4

qt-creator

Hi can anyone help me to convert LPTSTR to QString

like image 898
Sijith Avatar asked Dec 02 '22 05:12

Sijith


2 Answers

You will see in the docs that Qstring provides static function to convert from both ascii and Unicode strings:

  • QString fromAscii ( const char * ascii, int len = -1 )
  • QString fromLatin1 ( const char * chars, int len = -1 )
  • QString fromUtf8 ( const char * utf8, int len = -1 )
  • QString fromLocal8Bit ( const char * local8Bit, int len = -1 )
  • QString fromUcs2 ( const unsigned short * str )

Check whether you are using ascii or unicode and pick your poison.

like image 174
User2400 Avatar answered Dec 05 '22 18:12

User2400


QString::fromWCharArray is what worked for me.

like image 39
lapis Avatar answered Dec 05 '22 19:12

lapis