Results 1 to 14 of 14

Thread: How to create in memory QFile

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: How to create in memory QFile

    Quote Originally Posted by sonulohani View Post
    Ok. For that, i think dont add the file in the resource folder,except that, directly create it in your project folder and access it from there. Because if you put your file in the resource and it will get compile and you'll not able to edit it. For that,

    Qt Code:
    1. QFile *file;
    2. file=new QFile("demo.txt");.
    3. if (!file->open(QIODevice::WriteOnly | QIODevice::Text))
    4. return;
    5.  
    6. QTextStream out(file);
    7. out << "The magic number is: " << 49 << "\n";
    8.  
    9. file->close(); //for closing the file.
    To copy to clipboard, switch view to plain text mode 
    contains leaks...

    Why put QFile on the heap at all?

    If op wants to write/print QTextDocument, then he should familiarise himself with http://doc.qt.io/qt-4.8/qtextdocumentwriter
    Last edited by amleto; 2nd August 2012 at 13:37.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. QFile &QFile::operator= is private
    By Fallen_ in forum Newbie
    Replies: 1
    Last Post: 15th March 2011, 15:08
  2. Replies: 3
    Last Post: 26th March 2010, 07:26
  3. Replies: 5
    Last Post: 27th May 2009, 12:49
  4. create Memory-mapped file
    By weixj2003ld in forum Newbie
    Replies: 2
    Last Post: 17th April 2009, 10:47
  5. how to create html file in memory
    By darksaga in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2007, 09:30

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.