Results 1 to 8 of 8

Thread: Using Multi-Byte in place of Unicode

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using Multi-Byte in place of Unicode

    There's two versions of CreateFile:
    CreateFileA takes a ASCII parameters (char *)
    CreateFileW takes Unicode parameters (wchar *)

    Typically, if you have Unicode defined, CreateFileW is aliases to CreateFile, else CreateFileA is aliased to CreateFile.

    You can still use either by using the proper names:

    Qt Code:
    1. QString foo = "\\\\.\\COM1";
    2. CreateFileW(foo.utf16(), ...)
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. char foo[] = "\\\\.\\COM1";
    2. CreateFileA(foo, ...)
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to squidge for this useful post:

    TheDuncan (12th March 2010)

  3. #2
    Join Date
    Mar 2010
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Using Multi-Byte in place of Unicode

    Thanks a bunch. I used CreateFileA and it seems to be working.

    I'm new to Qt so I have a noob question to ask. How can I display a long in a Line Edit? I tried this

    Qt Code:
    1. QString number(lmsDist[20], 10);
    2. ui->txtAhead->setText(number);
    To copy to clipboard, switch view to plain text mode 

    but it just inserts blank spaces. I used debugging mode to check what lmsDist[540] was and it was an actual number (6530, 87, etc). What am I doing wrong?

    Thanks again with your help.

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using Multi-Byte in place of Unicode

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    TheDuncan (12th March 2010)

  6. #4
    Join Date
    Mar 2010
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Using Multi-Byte in place of Unicode

    Works like a champ. Thanks a million!

Similar Threads

  1. Converting from char to byte
    By Ferric in forum Newbie
    Replies: 2
    Last Post: 8th January 2010, 00:27
  2. Byte shifting in C
    By tntcoda in forum General Programming
    Replies: 3
    Last Post: 14th November 2008, 22:40
  3. Two Byte character Support
    By rajveer in forum General Programming
    Replies: 10
    Last Post: 25th October 2008, 00:29
  4. convert BYTE* to QString
    By tpf80 in forum Qt Programming
    Replies: 6
    Last Post: 8th April 2007, 10:29
  5. Can QByteArray takes place of BYTE?
    By hiuao in forum Qt Programming
    Replies: 2
    Last Post: 5th April 2007, 11:49

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
  •  
Qt is a trademark of The Qt Company.