I need to receive binary data(reading float) through a QTcpSocket and write them into Qfile using QDatastream. But I am having some problems with QDataStream. As follows, I can only achieve it using this way :
QDataStream in(socket);
in.setFloatingPointPrecision ( QDataStream::SinglePrecision);
float data;
in >> data;
QFile file("file.dat");
file.open(QIODevice::WriteOnly);
QDataStream out(&file);
out << data;
I have to create two Qdatastream and write float into Qfile after reading it.I mean, can I read stream and write it into file directly by one Qdatastream in order to getting more efficient.
Am I having some blind spot about the usage of QDataStream?Anyone can help me to solved my problem?Many thanks.