Skip to content

Instantly share code, notes, and snippets.

@ashumeow
Forked from diniremix/create_file_Qt
Created May 16, 2018 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashumeow/a229d90d5b0d2301520b1ea1941c6407 to your computer and use it in GitHub Desktop.
Save ashumeow/a229d90d5b0d2301520b1ea1941c6407 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