Problems to compile (Unicode)
Hello,
i'm new in QT and i don't know many things about it so i need your help ^^
i'm trying to compile the library "wiiyourself" with QT but i have few problems. it runs on visual c++ but not on QT.
the principal problem is "error: cannot convert 'const char*' to 'const TCHAR*' ..."
i have heard that it's about Unicode wich isn't support by QT but how can i solve it?
(excuse my language i'm not english :s )
Thanks!
Re: Problems to compile (Unicode)
1. What use function WinApi?
To solve this problem - see the source code in Qt4 and look where macros type QT_WA ;)
Re: Problems to compile (Unicode)
Quote:
i have heard that it's about Unicode wich isn't support by QT but how can i solve it?
Qt does support Unicode coding, it's even a foundation of QString!
TCHAR is a typedef from Microsoft which can be expand to the following:
Code:
#ifdef UNICODE
typedef wchar_t TCHAR;
#else
typedef char TCHAR;
#endif
TCHAR is char when you compile for multi-byte and wchar_t for unicode.
Quote:
it runs on visual c++ but not on QT
It should as it is a typedef from Microsoft.
Quote:
"the principal problem is "error: cannot convert 'const char*' to 'const TCHAR*' ..."
It means that you are using , at least, one function which needs at least one const TCHAR* as an argument.
As far as i know , TCHAR is not defined in Qt so you have to do the proper conversion by yourself for those functions which needs this argument type.
Re: Problems to compile (Unicode)
show us code, that brings "error: cannot convert 'const char*' to 'const TCHAR*' ..."
Re: Problems to compile (Unicode)
i can't use winapi, it's for a school project and i have to use qt...
i tried tu put in my code the definition of UNICODE that you give me but it has errors at the same place : cannot convert 'const char*' to 'const wchar_t*' in initialization
i give you 2 examples of fonctions wich give errors :
const TCHAR* wiimote::ButtonNameFromBit [16] = { _T("Left") , _T("Right"), _T("Down"), _T("Up"), _T("Plus") , _T("??") , _T("??") , _T("??") , _T("Two") , _T("One") , _T("B") , _T("A") , _T("Minus"), _T("??") , _T("??") , _T("Home") };
WARN(_T("couldn't create sample thread!"));
Re: Problems to compile (Unicode)
You are mixing Qt type and Microsoft type in your code, hence the error you get since you haven't surely done the necessary conversion.
Code:
const TCHAR* wiimote::ButtonNameFromBit [16] = { _T("Left") , _T("Right"), _T("Down"), _T("Up"), _T("Plus") , _T("??") , _T("??") , _T("??") , _T("Two") , _T("One") , _T("B") , _T("A") , _T("Minus"), _T("??") , _T("??") , _T("Home") };
That is an array of 16 pointers to const TCHAR.
How do your use this array in your code?
Re: Problems to compile (Unicode)
well, the librarie "wiiyourself " was already written by another one, if ou want to see it : http://wiiyourself.gl.tter.org/
doesn't matter how well the fonctions are coded, i just want to use it. how can i change the code to be Qt type on this example ??
Thanks