Results 1 to 3 of 3

Thread: How can I read binary data to QString?

  1. #1
    Join Date
    Jun 2008
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How can I read binary data to QString?

    Can I read binary data (for example 9 bytes) directly to QString from file? fread does not work with QString for me (requires char*), QDataStream also requires char* and serialized data example does not appear to be sutable for binary data.
    Last edited by zolookas; 29th July 2008 at 18:15. Reason: added url

  2. #2
    Join Date
    Jul 2008
    Location
    Netherlands
    Posts
    33
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I read binary data to QString?

    How about using QDataStream::readRawData()?

    http://doc.trolltech.com/4.3/qdatastream.html#raw

    edit: Nevermind, I misread your post. Sorry...

    Can you use QString::data() and cast that (QChar) pointer to a regular char* ?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How can I read binary data to QString?

    QByteArray is the appropriate class are when you need to store raw binary data.
    J-P Nurmi

Similar Threads

  1. Read binary file and convert to QString
    By jaca in forum Qt Programming
    Replies: 12
    Last Post: 14th June 2008, 00:05
  2. Reading binary data
    By vermarajeev in forum Qt Programming
    Replies: 1
    Last Post: 13th August 2007, 10:14
  3. QString static callback function from CURL
    By tpf80 in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2007, 21:47
  4. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 18:59
  5. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 17:17

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.