I'm mostly using Qt framework in C++. Can anyone explain me the advantages of using textstream objects instead of using directly objects?
Here is an example code without a QTextStream;
QFile file("asd.txt");
// assuming that file exists
file.open(QIODevice::Append);
file.write("asd");
file.close();
What are the advantages (or disadvantages) of using below code instead the above one;
QFile file("asd.txt");
// assuming that file exists
file.open(QIODevice::Append);
QTextStream tStream(file);
file << "asd";
file.close();
Thanks in advance.
QFile::write
either writes a nul terminated C string, or binary data that you give it.
QTextStream
on the other hand does text formatting/conversion.
tStream.flush();
before you close the file.