I need to pass this line to another library that takes a const char * argument. How to get const char *, please? I tried toLocal8bit (), toLatin1 (), toUtf8 () all without any luck. It seems like I'm missing something ...
Because if you try them, you will only get a QByteArray, not a const char *. You can use the constData () method in the QByteArray that you got in this way, and then you will have the desired result.
Mixing std :: string and QString is not required, so it is better to go through the qt types (QString → QByteArray → const char *) without entering std :: string here.
Where you use toLocal8bit (), toLatin1 () or toUtf8 () depends on your encoding, so this is another question to the main here. All of them will return you a QByteArray.
Note: you should avoid using toAscii (), although this is well said in Qt 5.
lpapp source share