CASE
- my Qt application create a file by QFile
- I intend to use dll to read this file
SYMPTOM
- dll cant use it, because it's occupied by the QAppilcation
ATTEMPT
- I tried file.close() to release the file, does not work;
- I tried other application to read this file, same symptom as occupied, which means dll is fine.
So, What can I do to release a file that is already created and closed by QFile?
Release the Qt file
void MainWindow::creatFile(){
QFile file("1.dat");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return ;
if(!file.exists())
return;
QTextStream out(&file);
out << "test" <<endl;
out.flush();
file.close(); // .~QFile() is not needed at all.
return;
}
convert QString to Character(Fortran)
typedef void (* myfun)(char string[255]); //How Qt pass character to Fortran dll
//QString-> std::string -> char*
std::string fileName_std = fileName.replace("/","\\").toStdString();
const char* fileName_cstr = fileName_std.c_str();
char fileName_For90[255];
int length = sizeof(fileName_For90);
//fill the left nulls of char with blanks which are required in Fortran
strcpy(fileName_For90,fileName_cstr);
for(int i = strlen(fileName_For90); i < length; i++){
fileName_For90[i] = ' ';
}
SHARE=
? It is not standard Fortran. – Vladimir F