This is my 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->plainTextEdit->toPlainText();
QTextStream out(&file);
out << text ;
file.close();
}
}
}
After calling the method through a pushButton
no file txt
is created.
connect(ui->saveButton, SIGNAL(clicked(bool)), this, SLOT(save()));
This is the message that appears in the Log:
QIODevice :: write (QFile, "C: \ Users \ kfg \ Desktop"): device not open