[Qt-interest] How to convert a LPCTSTR into a QString

Matthias Pospiech matthias.pospiech at gmx.de
Wed Jun 16 23:18:30 CEST 2010


I have a Windows Message call containing a LPCTSTR, which is defined as

#ifdef UNICODE
    typedef WCHAR TCHAR;
#else
    typedef CHAR TCHAR;
#endif
typedef const TCHAR *LPCTSTR;

If I now try to convert using:

void Controller::Error(LPCTSTR errorMessage)
{
    emit errorOccurred(QString::fromLocal8Bit(errorMessage));
}

I get the error:
error: no matching function for call to 'QString::fromLocal8Bit(const 
TCHAR*&)'

what should the solution look like?

Matthias




More information about the Qt-interest-old mailing list