PDA

View Full Version : reading String from binary files



sajastu
15th January 2015, 21:45
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:


QFile file("Users.dat");
file.open(QIODevice::WriteOnly | QIODevice::Append);
QDataStream out(&f);
out.setByteOrder(QDataStream::LittleEndian);
out<<ui->Pass_signUp->text()<<"$"<<ui->User_signUp->text();
file.close();


thanks in advance,

wysota
15th January 2015, 22:16
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).