Well, if you click OK, then InputFileName() will return the filename you have selected.

Since that filename is not "", you are getting into the else case of your if condition in writ_file, which again calls InputFileName().

And this of course shows the dialog again and again requires you to click either OK or Cancel.

I think want you want to do is

Qt Code:
  1. void writ_file() {
  2. QString fileName = InputFileName();
  3. if(fileName == "" ) {
  4. qDebug() << "Input file name -> cancelled. Uses the default name : "
  5. << file_name << endl;
  6. }
  7. else file_name = fileName;
  8. qDebug() << "writ_file() -> " << file_name;
  9. return;
  10. }
To copy to clipboard, switch view to plain text mode 

Btw, instead of returning "" just return QString() and instead of checking == "", check fileName.isEmpty()

Cheers,
_