Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can my app provide resources loaded by a Qt library?

Can my app provide resources loaded by a Qt library?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 897 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Tom assoT Offline
    Tom assoT Offline
    Tom asso
    wrote on last edited by Tom asso
    #1

    For example, the Qt DataVisualization library loads a shader that’s specified in the library source code as “:/shaders/vertexSurfaceFlat”, and that shader is located in a shaders/ subdirectory in the source code directory. I would like my app that utilizes the library to “convince” the library to use an alternate shader, but I don’t want to modify library source code or library shaders. Is there a way my app can provide its own version of “:/shaders/vertexSurfaceFlat” for the library to load?

    Thanks!

    JKSHJ 1 Reply Last reply
    0
    • Tom assoT Tom asso

      For example, the Qt DataVisualization library loads a shader that’s specified in the library source code as “:/shaders/vertexSurfaceFlat”, and that shader is located in a shaders/ subdirectory in the source code directory. I would like my app that utilizes the library to “convince” the library to use an alternate shader, but I don’t want to modify library source code or library shaders. Is there a way my app can provide its own version of “:/shaders/vertexSurfaceFlat” for the library to load?

      Thanks!

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @Tom-asso said in Can my app provide resources loaded by a Qt library?:

      Is there a way my app can provide its own version of “:/shaders/vertexSurfaceFlat” for the library to load?

      A resource file is embedded into the built binary. A path like “:/shaders/vertexSurfaceFlat” tells Qt to use the embedded file.

      If you want the library to load an alternate file, then the library must accept an alternate path. If the path is hard-coded into the library, then it cannot load an alternate file.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      Tom assoT 1 Reply Last reply
      2
      • JKSHJ JKSH

        @Tom-asso said in Can my app provide resources loaded by a Qt library?:

        Is there a way my app can provide its own version of “:/shaders/vertexSurfaceFlat” for the library to load?

        A resource file is embedded into the built binary. A path like “:/shaders/vertexSurfaceFlat” tells Qt to use the embedded file.

        If you want the library to load an alternate file, then the library must accept an alternate path. If the path is hard-coded into the library, then it cannot load an alternate file.

        Tom assoT Offline
        Tom assoT Offline
        Tom asso
        wrote on last edited by Tom asso
        #3

        @JKSH - thanks.
        So how does library source code specify an "alternate path" versus "hard-coded path"?

        JKSHJ 1 Reply Last reply
        0
        • Tom assoT Tom asso

          @JKSH - thanks.
          So how does library source code specify an "alternate path" versus "hard-coded path"?

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @Tom-asso said in Can my app provide resources loaded by a Qt library?:

          So how does library source code specify an "alternate path" versus "hard-coded path"?

          In my previous post, "alternate path" means "a path that is different from :/shaders/vertexSurfaceFlat".

          If the path is "hard-coded", it means that the path is written in the source code as a string literal. The opposite of "hard-coded" is "programmatic".

          void openFiles(const QString &filePath) {
              QFile file1("hello.txt"); // Hard-coded path
              QFile file2(filePath); // Programmatic path
          
              // ...
          }
          

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          Tom assoT 1 Reply Last reply
          4
          • JKSHJ JKSH

            @Tom-asso said in Can my app provide resources loaded by a Qt library?:

            So how does library source code specify an "alternate path" versus "hard-coded path"?

            In my previous post, "alternate path" means "a path that is different from :/shaders/vertexSurfaceFlat".

            If the path is "hard-coded", it means that the path is written in the source code as a string literal. The opposite of "hard-coded" is "programmatic".

            void openFiles(const QString &filePath) {
                QFile file1("hello.txt"); // Hard-coded path
                QFile file2(filePath); // Programmatic path
            
                // ...
            }
            
            Tom assoT Offline
            Tom assoT Offline
            Tom asso
            wrote on last edited by Tom asso
            #5

            @JKSH - I see. And if the library code also specifies an "alias" for the resource, there is still no way around the absolute path? E.g. if the library's qrc file contains:

               <qresource prefix="/shaders">
                    <file alias="fragment">shaders/default.frag</file>
             
            

            Thanks!

            JKSHJ 1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Just to be sure I understand you, you would like to somehow replace the shader loaded by Qt Datavizualisation with your own ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • Tom assoT Tom asso

                @JKSH - I see. And if the library code also specifies an "alias" for the resource, there is still no way around the absolute path? E.g. if the library's qrc file contains:

                   <qresource prefix="/shaders">
                        <file alias="fragment">shaders/default.frag</file>
                 
                

                Thanks!

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by JKSH
                #7

                @Tom-asso said in Can my app provide resources loaded by a Qt library?:

                And if the library code also specifies an "alias" for the resource, there is still no way around the absolute path?

                Nope. An alias is still a hard-coded path as it cannot be changed at runtime.

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved