josecarlosmissias
24th November 2009, 15:12
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.
high_flyer
24th November 2009, 15:54
Look at the the LPSTR difintion, and you will see its typedef CHAR*...
josecarlosmissias
24th November 2009, 19:57
Look at the the LPSTR difintion, and you will see its typedef CHAR*...
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 * '
squidge
24th November 2009, 20:52
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.