Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-113396

"Explicit Loading and Unloading of Embedded Resources" needs elaboration

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • 6.5.0
    • None
    • All

      https://doc.qt.io/qt-6/resources.html#explicit-loading-and-unloading-of-embedded-resources

      In this section, it's said that the developer must manually use Q_INIT_RESOURCE when they build the app statically.

      The provided code snippet is this:

       

      MyClass::MyClass() : BaseClass()
      {
          Q_INIT_RESOURCE(resources);
      
          QFile file(":/myfile.dat");
          ...
      } 

      In my opinion, it could give readers some questions, such as

       

      1. In this snippet, the Q_INIT_RESOURCE() is used in the user-defined class. Does it mean the developer should call it whenever he wants to use a file in a specific qrc file?
      2. If so, isn't it broating the code too much? -> less maintenability
      3. Also, if that's the case, should resource files, such as png files, be packed together in each .qrc file which is used in different places? Doesn't it lead to many qrc files and possible maintenance nightmare?
      4. Can we just call Q_INIT_RESOURCE in one place and that's all? <- imo, showing this way is the best.

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            hjk hjk
            mikio_hirai Mikio Hirai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes