Open binary file for write-operation
#include <QFile> #include <QTextStream> int main() { QFile file("out.dat"); if (!file.open(QIODevice::WriteOnly)) return 1; QDataStream out(&file); out << "The magic number is: " << 49 << "\n"; }