Results 1 to 3 of 3

Thread: How to get QByteArray from QString in Qt3

  1. #1
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default How to get QByteArray from QString in Qt3

    Hi,


    How to get QByteArray from QString object in Qt3..??



    thanks in advance.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get QByteArray from QString in Qt3

    You could try QString::local8Bit().
    But depends what you want to do with the byte array.
    You could also use QString::utf8, but really, depends on your encoding.

    Regards

  3. #3
    Join Date
    Sep 2007
    Location
    Finland
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get QByteArray from QString in Qt3

    this might work as well...

    Qt Code:
    1. QStringList string("some text");
    2. QByteArray bytearray;
    3. QDataStream stream( bytearray, IO_ReadWrite );
    4. stream << string.latin1();
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 5th September 2007 at 17:34. Reason: changed [qtclass] to [code]

Similar Threads

  1. QString static callback function from CURL
    By tpf80 in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2007, 20:47
  2. Replies: 5
    Last Post: 16th March 2007, 08:18
  3. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  4. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:10
  5. [SOLVED] Widget plugin ... how to ?
    By yellowmat in forum Newbie
    Replies: 10
    Last Post: 29th January 2006, 20:41

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.