Hello everyone,
I'm loading a library in "C" and its functions require parameters of type LPSTR.
Do you have any way to convert QString to LPSTR?
Grateful.
Hello everyone,
I'm loading a library in "C" and its functions require parameters of type LPSTR.
Do you have any way to convert QString to LPSTR?
Grateful.
Last edited by josecarlosmissias; 24th November 2009 at 15:21.
Look at the the LPSTR difintion, and you will see its typedef CHAR*...
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
right, how do I convert QString to char *, eg:
//--------------------
typedef int (* CaptTxtDllECF) (int type, char * faixai, faixaf char *, char * path, int show char * str);
....
//------------------
QString pathToSave = "c:\\tmp\\lx.txt";
status = captTxtDllECF (_LX, "", "", path, 1, "serial");
error:
C: / workspace / captureW /. / Main.cpp: 227: error: 'int (int, char *, char *, char *, int, char *)': can not convert parameter 4 from 'QString' to 'char * '
Well, QString has a toLocal8Bit method, and QByteArray has a method constData to return a const char *. Or you use Data instead to remove the const'ness. Its better to use the former unless you need to modify the string however.
josecarlosmissias (24th November 2009)
Bookmarks