Home > Back-end >  QT file creation in question
QT file creation in question

Time:09-17

Want to ask everybody a great god, and why the path is right but can't create file
Path2 is get into the folder path where you need to create a new file
Path2=path2 + + qStr '/';
QFile savefile (path2);
Manually rewrite the path will be a problem

CodePudding user response:

The look in the full path is hit, or debug it and see what is error?

CodePudding user response:

No wrong, is unable to generate the file, the full path below

CodePudding user response:

You have to open, then write

CodePudding user response:

Is there a call Open?
 
Void the write (QString filename)
{
QFile file (filename);
if(! File. The open (QFile: : WriteOnly | QFile: : Text))
{
QDebug () & lt; <"Could not open file for writing";
return;
}

QTextStream out (& amp; The file);
The out & lt; <"QFile Tutorial";
File. The flush ();
File. The close ();
}
  • Related