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

Qt Code:
  1. // Save the file
  2. QFile fileOne("test.file");
  3. fileOne.open(QIODevice::WriteOnly);
  4. QDataStream out(&fileOne);
  5. out.setVersion(QDataStream::Qt_4_6);
  6. out << "Test";
  7. fileOne.close();
  8.  
  9. //load from it
  10. QFile file("test.file");
  11. file.open(QIODevice::ReadOnly);
  12. QDataStream in(&file);
  13. QString str;
  14. in.setVersion(QDataStream::Qt_4_6);
  15. in >> str ;
  16.  
  17. QString strLength;
  18. strLength.setNum(str.length());
  19.  
  20. QMessageBox::information(0,"Output",str);
  21. QMessageBox::information(0,"Output",strLength);
  22. file.close();
To copy to clipboard, switch view to plain text mode