Results 1 to 2 of 2

Thread: reading String from binary files

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default reading String from binary files

    Hi,
    im almost new in Qt! how can i read Strings from Binary files? (Strings which i already saved in binary file)
    this is part of my code that writes data(String) to bin file, you see:
    Qt Code:
    1. QFile file("Users.dat");
    2. file.open(QIODevice::WriteOnly | QIODevice::Append);
    3. QDataStream out(&f);
    4. out.setByteOrder(QDataStream::LittleEndian);
    5. out<<ui->Pass_signUp->text()<<"$"<<ui->User_signUp->text();
    6. file.close();
    To copy to clipboard, switch view to plain text mode 

    thanks in advance,

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

    Default Re: reading String from binary files

    Are you sure you know what you are doing? QDataStream is a serialization mechanism, not a general purpose binary stream. If you insist on using it then simply reverse the direction of streaming operators (of course read to variables and then set them on the widgets).
    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.


Similar Threads

  1. Re: Reading binary files using readAll problem [SOLVED]
    By Miss Engineer in forum Qt Programming
    Replies: 0
    Last Post: 18th September 2014, 15:57
  2. Reading a binary file with QT
    By YuriyRusinov in forum Qt Programming
    Replies: 7
    Last Post: 21st December 2012, 07:14
  3. Reading string in Utf8 from binary file
    By iddqd in forum Newbie
    Replies: 3
    Last Post: 19th July 2010, 06:16
  4. Reading Binary Files
    By archanasubodh in forum Newbie
    Replies: 1
    Last Post: 27th February 2008, 12:31
  5. Reading binary data
    By vermarajeev in forum Qt Programming
    Replies: 1
    Last Post: 13th August 2007, 09:14

Tags for this Thread

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.