title: I can't save .txt file with QFileDialog, C++ QT
body: <p>This is my code:</p>
  
  <pre><code>void MainWindow::save(){
      QString fileName = QFileDialog::getSaveFileName(this, tr("Save Text File"), path, tr("Text Files (*.txt)"));
      if (fileName != "")
      {
         QFileInfo info(fileName);
         path = info.absoluteDir().absolutePath();
         QFile file(path);
         if(!file.open(QIODevice::WriteOnly)){
             QString text = ui-&gt;plainTextEdit-&gt;toPlainText();
             QTextStream out(&amp;file);
             out &lt;&lt; text ;
             file.close();
         }
      }
  }
  </code></pre>
  
  <p>But it doesn't create any .txt file after click a pushButton:</p>
  
  <pre><code>connect(ui-&gt;saveButton, SIGNAL(clicked(bool)), this, SLOT(save()));
  </code></pre>
  
  <p>Log:</p>
  
  <pre><code>QIODevice::write (QFile, "C:\Users\kfg\Desktop"): device not open
  </code></pre>
  
  <p>Thanks for your help :)</p>