Results 1 to 7 of 7

Thread: Problems to compile (Unicode)

  1. #1
    Join Date
    Apr 2010
    Posts
    17
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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!

  2. #2
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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

  3. #3
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems to compile (Unicode)

    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:
    Qt Code:
    1. #ifdef UNICODE
    2. typedef wchar_t TCHAR;
    3. #else
    4. typedef char TCHAR;
    5. #endif
    6. TCHAR is char when you compile for multi-byte and wchar_t for unicode.
    To copy to clipboard, switch view to plain text mode 

    it runs on visual c++ but not on QT
    It should as it is a typedef from Microsoft.

    "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.

  4. #4
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems to compile (Unicode)

    show us code, that brings "error: cannot convert 'const char*' to 'const TCHAR*' ..."

  5. #5
    Join Date
    Apr 2010
    Posts
    17
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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!"));

  6. #6
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.
    Qt Code:
    1. 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") };
    To copy to clipboard, switch view to plain text mode 
    That is an array of 16 pointers to const TCHAR.
    How do your use this array in your code?
    Last edited by toutarrive; 9th April 2010 at 17:46.

  7. #7
    Join Date
    Apr 2010
    Posts
    17
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

Similar Threads

  1. Problems trying to compile driver firebird
    By estanisgeyer in forum Qt Programming
    Replies: 3
    Last Post: 19th July 2011, 14:22
  2. Compile phonon problems...
    By webquinty in forum Newbie
    Replies: 0
    Last Post: 9th December 2009, 14:17
  3. Project compile problems
    By MarkoSan in forum Qt Programming
    Replies: 7
    Last Post: 15th October 2009, 12:54
  4. Qwt 4.2.0 compile problems
    By MarkoSan in forum Qwt
    Replies: 2
    Last Post: 28th September 2009, 09:15
  5. Problems with Unicode(UTF8)
    By cristiano in forum Qt Programming
    Replies: 15
    Last Post: 5th December 2006, 12:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.