QDataStream unable to serialize data
问题 I am trying to follow the tutorial here and serialize Qt objects. Here is my code: QFile file("/Users/kaustav/Desktop/boo.dat"); if (!file.open(QIODevice::WriteOnly)) { qDebug() << "Cannot open file for writing: " << qPrintable(file.errorString()) << endl; //no error message gets printed return 0; } QDataStream out(&file); // we will serialize the data into the file out.setVersion(QDataStream::Qt_5_3); //adding this makes no difference out << QString("the answer is"); // serialize a string