Results 1 to 6 of 6

Thread: adding files to resources by code

  1. #1

    Default adding files to resources by code

    Hi,

    Is there any way to add files (text ones) to recources by the code?
    When i'm saying adding i mean creating new txt file in resources location, and than write and read from it...

    if is posible pls example or method how to...

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: adding files to resources by code

    You cannot modify a resource while the application is executing (if that is what you are asking) as the resource is compiled into the application binary. What exactly do you need it for?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3

    Default Re: adding files to resources by code

    thanks for reply,

    I whanna make application that allows u to save some texts which would be only editable and readable by the same program...
    i don't whant to have folder full of .txt files

    soo what should i use than?

    i thought resources were made for that :/

  4. #4
    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: adding files to resources by code

    i thought resources were made for that :/
    Resources are generally used to contain files that you (the developer) add to the project. Things like image files for icons, for example. They are compiled into the executable so you don't have to ship the images files along with the app.

    Why don't you look at QSettings - this is intended to do exactly what you are describing, creating a text file of parameters or options used by a program to customize it to a user's needs.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: adding files to resources by code

    Alternatively a simple sqlite database can be used to store data in a single blob that accompanies the program.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: adding files to resources by code

    Even with text files there should be no problem.
    All moderns operating systems have application specific data locations, i.e. a folder for each app that it can store its data into.

    Cheers,
    _

Similar Threads

  1. Add files to resources dynamically
    By juracist in forum Qt Programming
    Replies: 2
    Last Post: 25th June 2014, 14:29
  2. Do resources in QRC files consume memory?
    By TheNewGuy in forum Newbie
    Replies: 1
    Last Post: 7th December 2009, 08:07
  3. Adding directories to resources
    By roxton in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2008, 12:00
  4. Resources files (.qrc) not working
    By degs2k4 in forum Qt Programming
    Replies: 16
    Last Post: 21st February 2008, 09:54
  5. Replies: 9
    Last Post: 11th January 2007, 15:34

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.