QDataStream写文件完成后,立马读时 读不读出来 为什么??
QFile file("file.dat");
file.open(QIODevice::WriteOnly);
QDataStream out(&file); // we will serialize the data into the file
out.setVersion(QDataStream::Qt_4_0);
out << QString("the answer is"); // serialize a string
out << (qint32)42; // serialize an integer
//读二进制文件
QFile file("file.dat");
file.open(QIODevice::ReadOnly);
QDataStream in(&file); // read the data serialized from the file
in.setVersion(QDataStream::Qt_4_0);
QString str;
qint32 a;
in >> str >> a; // extract "the answer is" and 42
qDebug()<<str<<a;