O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required