c++ - How to obtain const char * from QString -
i have read string in xml file utf8 encoding. store value in qstring
object , concatenate other information. can see in qtcreator debugger qstring
holds desired value.
i need pass string library takes const char *
argument. how obtain const char *
please? i've tried tolocal8bit()
, tolatin1()
, toutf8()
no luck. seems missing something...
i need pass string library takes const char * argument. how obtain const char * please? i've tried tolocal8bit(), tolatin1(), toutf8() no luck. seems missing something...
because if try those, qbytearray opposed const char*. use constdata() method on qbytearray got way, , have desired result.
mixing std::string , qstring not necessary, hence better go through qt types (qstring -> qbytearray -> const char*) without introducing std::string in here.
where use tolocal8bit(), tolatin1() or toutf8() depends on encoding, different question main 1 in here. return qbytearray you.
note: should avoid using toascii() though deprecated in qt 5 good.
Comments
Post a Comment