PDA

View Full Version : file not writing



sujan.dasmahapatra
25th October 2011, 22:22
I am just trying to write a file...but its not writing can u check whats wrong in this. the file should be generated in my current directory but there's no file generated.



QFile file("resumePDF.dat");

if(!file.open(QFile::WriteOnly))
console->mainwindow->statusBar()->showMessage(tr("file resumePDF.pdf cannot be opened for writing !!!"),5000);
QTextStream out(&file);
out << "My name is Sujan Dasmahapatra" << "\n";
file.close();

Lykurg
25th October 2011, 22:40
Is open() returning true? Try an absolute path for debugging and then see QDir::setCurrent() the set the current path.

ChrisW67
25th October 2011, 23:01
Something for after you manage to open a file...

If you intended writing a PDF document's binary data to the file then I suggest you do not want a QTextStream for reasons I hope would be obvious.