Results 1 to 4 of 4

Thread: Create files required by application from resource files?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Create files required by application from resource files?

    My application needs some files to executed properly. The files are needed for initialization of an embedded interpreter and the library functions only support passing a filename, not an open file descriptor.

    I can have the files live in a known directory, but they could get accidently deleted by accident. I'm wondering if there's a good way to create the files from Qt resources?

    I can have a trivial Qt method that copies the files at startup from their resource definitions into temporary files and use the copies.

    Is there a better way?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Create files required by application from resource files?

    Resources are compiled and linked into your program at build time. Are these configuration files constant (i.e. the same for every installation of the program)? If so, then you can just add them as resources in the QRC file and then can use them at runtime just like any other disk-based file. Just open them with the proper resource URL (qrc:///...) or file path (:/...) like you would when loading an icon. No need to copy them to a temporary file.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Resource files not showing on Ubuntu 16.04
    By EVARATE in forum Newbie
    Replies: 1
    Last Post: 14th April 2020, 23:28
  2. integrated + binary resource files
    By Le_B in forum Qt Quick
    Replies: 0
    Last Post: 5th June 2011, 16:45
  3. QDir::setCurrent with resource files
    By LarryERamey in forum Qt Programming
    Replies: 3
    Last Post: 20th April 2011, 02:21
  4. Replies: 1
    Last Post: 24th October 2009, 15:11
  5. How to compile qt resource files?
    By yangyunzhao in forum Qt Programming
    Replies: 1
    Last Post: 10th August 2009, 06:46

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.