Game Programming using Qt 5 Beginner's Guide - Second Edition
by Pavel Strakhov, Witold Wysota, Lorenz Haas
Text streams
Much of the data produced by computers nowadays is based on text. You can create such files using a mechanism that you already know—opening QFile to write, converting all data into strings using QString::arg(), optionally encoding strings using QTextCodec, and dumping the resulting bytes to the file by calling write. However, Qt provides a nice mechanism that does most of this automatically for you in a way similar to how the standard C++ iostream classes work. The QTextStream class operates on any QIODevice API in a stream-oriented way. You can send tokens to the stream using the << operator, where they get converted into strings, separated by spaces, encoded using a codec of your choice, and written to the underlying device. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access