Skip to content

Instantly share code, notes, and snippets.

@diniremix
Created December 4, 2011 06:00
Show Gist options
  • Save diniremix/1429352 to your computer and use it in GitHub Desktop.
Save diniremix/1429352 to your computer and use it in GitHub Desktop.
create file of text in Qt
void MainWindow::createfile(){
QString filename="test.txt";
QFile file(filename);
if(!file.exists()){
qDebug() << "NO existe el archivo "<<filename;
}else{
qDebug() << filename<<" encontrado...";
}
QString mesg="una segunda linea";
if (file.open(QIODevice::WriteOnly | QIODevice::Text)){
QTextStream out(&file);
out << "archivo de texto generado en Qt\n";
out<<mesg;
file.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment