Results 1 to 3 of 3

Thread: file not writing

  1. #1
    Join Date
    Feb 2009
    Posts
    189
    Thanks
    2

    Smile file not writing

    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.

    Qt Code:
    1. QFile file("resumePDF.dat");
    2.  
    3. if(!file.open(QFile::WriteOnly))
    4. console->mainwindow->statusBar()->showMessage(tr("file resumePDF.pdf cannot be opened for writing !!!"),5000);
    5. QTextStream out(&file);
    6. out << "My name is Sujan Dasmahapatra" << "\n";
    7. file.close();
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 25th October 2011 at 22:37. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: file not writing

    Is open() returning true? Try an absolute path for debugging and then see QDir::setCurrent() the set the current path.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: file not writing

    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.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

Similar Threads

  1. Writing to a txt file
    By nagabathula in forum Qt Programming
    Replies: 2
    Last Post: 7th May 2011, 11:59
  2. Writing a XML file
    By Djony in forum Qt Programming
    Replies: 7
    Last Post: 5th February 2007, 16:23
  3. Writing to file at specific
    By safknw in forum Qt Programming
    Replies: 3
    Last Post: 1st December 2006, 11:12
  4. XML file writing
    By mbjerkne in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2006, 19:04
  5. Writing an XML file
    By qball2k5 in forum Qt Programming
    Replies: 9
    Last Post: 19th March 2006, 10:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.