Hello,
Does anybody know what is wrong with next:
I need to create file in some directory with rw permissions on disk then write to it data and open after. On Windows and Linux, MacOS also.
For that I use next code:

Qt Code:
  1. ...
  2. QString outputDir = "some_dir"; // with "/" separators
  3. QString fileName = "some_file_name" + ".dat";
  4. QFile file(outputDir+"/"+fileName);
  5. if (!file.open(QIODevice::WriteOnly|QFile::WriteOnly))
  6. {
  7. QMessageBox::warning(0,"Could not create Project File",
  8. QObject::tr( "\n Could not create Project File on disk"));
  9.  
  10. return false;
  11. }
  12. else
  13. {
  14. QDataStream stream(&file);
  15. ...
  16. file.close();
  17. }
  18. ...
To copy to clipboard, switch view to plain text mode 

On Linux ( Ubuntu ) it works ok ( file.open(…) returns true ) – file is created , written , closed ,reopened ,read. But when I run the same code on Windows file.open(…) returns false in any directory I choose. It is written in Qt docs that Qt automatically treats right directory path names ( separators ) for underlying OS ( translates “/” ( default ) to underlying OS ).
I’ve tried to use QDir::toNativeSeparators(outputDir+”/”+fileName) inside file.open(…) but still the file couldn’t be created on Windows – file.open(…) returns false.
***
Does anybody can help/point what is wrong with creating new file on windows in this case ? ( what is wrong with file.open(…) ) ?
How to solve so that I can open new file on Windows using QFile?

Thank you in advance.