PDA

View Full Version : Convert from "mystring" to QString;



mut
14th June 2014, 00:23
Hello;

What is the best way (more portable - Linux and Windows, support for different character settings) to convert from either "mystring" or char* to QString?

I'm confused between:

QString fromAscii ( const char * str, int size = -1 )
QString fromLatin1 ( const char * str, int size = -1 )
QString fromLocal8Bit ( const char * str, int size = -1 )
QString fromRawData ( const QChar * unicode, int size )
QString fromStdString ( const std::string & str )

Thanks,

Mut

Infinity
14th June 2014, 02:31
It depends on the encoding of your C-style string because QString internally uses UTF-16 and thus needs to convert your string to UTF-16.