Results 1 to 4 of 4

Thread: Edit resource file of compiled executable

  1. #1
    Join Date
    Apr 2016
    Posts
    9
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Edit resource file of compiled executable

    I want to change the resource file(It contains an textfile with some settings) of an qt linux c++ application with another application.
    I know this is possible in c# and delphi because I did it there before. But is this possible in qt c++? And does someone has an example for me?

    This is what the resource file contains:
    Qt Code:
    1. <RCC>
    2. <qresource prefix="/">
    3. <file>settings.txt</file>
    4. </qresource>
    5. </RCC>
    To copy to clipboard, switch view to plain text mode 
    Last edited by jwz104; 10th August 2016 at 14:25.

  2. #2
    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: Edit resource file of compiled executable

    Qt resources, referenced by the qrc file, are compressed, converted to C++ code, and compiled into the Qt C++ program. This is distinctly different from the Windows Resources that you were likely editing in your Delphi/.Net programs: these are stored as blobs embeded in the same files as the compiled executable, but logically separate from it and addressable through an API. Windows resources can be edited, added and removed by third party products with no knowledge of the executable.

    You can use the Qt Resource Compiler to produce standalone binary files that can be loaded dynamically, and selected at run time.
    http://doc.qt.io/qt-4.8/resources.html

    You are free to use Windows resources in your Qt C++ program and the Windows API to access them. See the RC_FILE variable in qmake. This is not as convenient as the qt resource system for some applications.
    Last edited by ChrisW67; 10th August 2016 at 13:41.

  3. #3
    Join Date
    Apr 2016
    Posts
    9
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Edit resource file of compiled executable

    I forgot to say that it is a linux application?
    Is it now impossible?

  4. #4
    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: Edit resource file of compiled executable

    The platform doesn't change anything on how Qt's resources work.

    As ChrisW67 explained, the technique used here is to take the data, compress it and then generate C++ code (char arrays) and compile them like any manually written C++ code.

    QFile and QDir know about these "files" and map them into a kind of virtual filesystem, so Qt classes that expect a file name or URL can still access the data.
    The data is not a real file anymore though.

    Just like any normal char array constant that data is now part of the executables read-only section, which makes it shared between multiple instances of the same program.

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    jwz104 (11th August 2016)

Similar Threads

  1. How can I edit resource file?
    By neda in forum Qt Programming
    Replies: 1
    Last Post: 12th April 2016, 06:54
  2. Replies: 2
    Last Post: 18th March 2016, 11:51
  3. How to edit internal data in a executable
    By Momergil in forum Newbie
    Replies: 4
    Last Post: 20th October 2011, 09:46
  4. Failed to Launch qt 4.4.0 compiled executable in Debug mode
    By nikhilqt in forum Installation and Deployment
    Replies: 2
    Last Post: 25th July 2008, 13:45
  5. Replies: 5
    Last Post: 4th December 2007, 18:24

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.