Affenbrotbaum
28th January 2010, 21:02
Hey Community,
I am running the following piece of code on a Windows 7 machine and the output seems really strange. I get a string length of 0 back.
Am I missing something?
Thanks a lot
Alex
// Save the file
QFile fileOne("test.file");
fileOne.open(QIODevice::WriteOnly);
QDataStream out(&fileOne);
out.setVersion(QDataStream::Qt_4_6);
out << "Test";
fileOne.close();
//load from it
QFile file("test.file");
file.open(QIODevice::ReadOnly);
QDataStream in(&file);
QString str;
in.setVersion(QDataStream::Qt_4_6);
in >> str ;
QString strLength;
strLength.setNum(str.length());
QMessageBox::information(0,"Output",str);
QMessageBox::information(0,"Output",strLength);
file.close();
I am running the following piece of code on a Windows 7 machine and the output seems really strange. I get a string length of 0 back.
Am I missing something?
Thanks a lot
Alex
// Save the file
QFile fileOne("test.file");
fileOne.open(QIODevice::WriteOnly);
QDataStream out(&fileOne);
out.setVersion(QDataStream::Qt_4_6);
out << "Test";
fileOne.close();
//load from it
QFile file("test.file");
file.open(QIODevice::ReadOnly);
QDataStream in(&file);
QString str;
in.setVersion(QDataStream::Qt_4_6);
in >> str ;
QString strLength;
strLength.setNum(str.length());
QMessageBox::information(0,"Output",str);
QMessageBox::information(0,"Output",strLength);
file.close();