I found an example of this type:
tr("File di Testo (*.txt);;C++ File (*.cpp *.h)"));
if (nomeFile != "") {
stream << ui->editaTesto->toPlainText();
file.flush();
file.close();
}
else {
QMessageBox::critical(this, tr
("Errore"), tr
("Non posso salvare il file"));
return;
}
}
QString nomeFile = QFileDialog::getSaveFileName(this, tr("Salva il File"), "",
tr("File di Testo (*.txt);;C++ File (*.cpp *.h)"));
if (nomeFile != "") {
QFile file(nomeFile);
if (file.open(QIODevice::ReadWrite)) {
---> QTextStream stream(&file); <-----
stream << ui->editaTesto->toPlainText();
file.flush();
file.close();
}
else {
QMessageBox::critical(this, tr("Errore"), tr("Non posso salvare il file"));
return;
}
}
To copy to clipboard, switch view to plain text mode
When I compile I get this error message referring to the line of code with the arrows:
C:\Qt\progetti\test-MainWindow\notepad.cpp:46: error: variable 'QTextStream stream' has initializer but incomplete type
C:\Qt\progetti\test-MainWindow\notepad.cpp:46: error: variable 'QTextStream stream' has initializer but incomplete type
To copy to clipboard, switch view to plain text mode
How should I write?
Thanks to all
Bookmarks