QString to LPCTSTR conversion
-
HI All
I am using win32 dll in my -QT- Qt Application.
win32 dll has one function which takes parameter of type LPCTSTR.
When i try to call this function from my Qt Application passing QString as parameter function is not recieveng the correct value .
How to resolve this? -
Try "QString::toWCharArray() ":http://doc.qt.nokia.com/4.7/qstring.html#toWCharArray.
-
If it is a pure in parameter, you can try:
@
void fooSub(LPSTSTR X); // this is our function :-)foo()
{
QString text;
if(sizeof(TCHAR) == 1)
fooSub((LPCSTR)text.toLocal8Bit().constData()); // here you have to check, how to convert, you could also use utf8(), ...
else
fooSub((LPCWSTR)text.utf16());
}
@