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. How could I register the files do not under the directories of Qt resource system
Forum Updated to NodeBB v4.3 + New Features

How could I register the files do not under the directories of Qt resource system

Scheduled Pinned Locked Moved General and Desktop
16 Posts 2 Posters 7.4k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #7

    [quote author="SGaist" date="1371712668"]Then you only have to add the qrc in your application pro file and you should be good
    [/quote]

    I add it into my .pro already

    @RESOURCES +=
    qrc.qrc@

    the problem is the resource system of Qt
    do not accept the resources which do not under the folder.

    message of QtCreator when I intent to add the shaders

    The file /Users/Qt/program/libs/ShadersEffects/toGray.fsh is not in a subdirectory of the resource file. You now have the option to copy this file to a valid location.

    parent/libs/ShaderEffects -- the location of my shaders
    parent/apps/colorEnhance -- the location of my app, the .pro and the
    qrc are under this folder

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

      Then try to move the qrc in Shader effects and do

      @
      RESOURCES += ../ShaderEffects/qrc.qrc
      @

      You might also want to change the qrc name to shaders.qrc it would be cleaner

      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
      • S Offline
        S Offline
        stereomatching
        wrote on last edited by
        #9

        Thanks for your help, as you suggested, change the qrc name would make the project easier to maintain.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stereomatching
          wrote on last edited by
          #10

          I add the qrc as you suggested, but there area problem

          After I make my "main.qml" become a file in the qrc
          the program always complain it cannot find the directory

          .pro
          @
          RESOURCES +=
          ../../experiment_libs/qmlHelper/shaderSupport/support.qrc \
          qrc.qrc
          @

          main.cpp
          @
          #include <QtQuick/QQuickView>
          #include <QGuiApplication>
          #include <QtDeclarative/QDeclarativeEngine>
          #include <QQmlEngine>

          int main(int argc, char *argv[])
          {
          QGuiApplication app(argc, argv);

          QQuickView view;    
          view.setResizeMode(QQuickView::SizeRootObjectToView);
          view.setSource(QStringLiteral("qrc:/main.qml"));
          view.show();
          
          return app.exec();
          

          }

          @

          main.qml
          @
          import QtQuick 2.1

          import "../../commercial_libs/qmlHelper/shaderSupport"

          Rectangle {
          width: 100
          height: 62

          Image{
              anchors.fill: parent
          
              source: "file:///Users/et/Downloads/1360800908784.jpg"
          
              ImageEffect{
                  source: parent            
              }
          }
          

          }

          @

          error message

          qrc:/main.qml:3:1: "../../experiment_libs/qmlHelper/shaderSupport": no such directory

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

            The folder where your application is started is not the same as your source folder.

            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
            • S Offline
              S Offline
              stereomatching
              wrote on last edited by
              #12

              [quote author="SGaist" date="1372248015"]The folder where your application is started is not the same as your source folder.
              [/quote]
              Yes, I do not put them in the same folder
              because it should belongs to other module
              if this is the limit of qrc, then I have to find another solution

              ex :
              1 : copy the files of other folder into my source folder
              and add them into the qrc, could .pro handle this kind of jobs?
              Or I have to write some script according to different platforms?
              Maybe use Qt to write a simple app to handle the cross platform
              issues would be a better solution

              2: just wrapped those shader codes as .hpp and .cpp

              The second solution

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

                Wait: what do you want to import from that path ?

                If it's the shaders, since you have them in your qrc get them from the qrc

                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
                • S Offline
                  S Offline
                  stereomatching
                  wrote on last edited by
                  #14

                  Part of them are qrc, part of them are qml components
                  I was confuse by the error messages, looks like I could access
                  the shaders in qrc even it is not under my source folders

                  Now the problem is how could I access the qml do not under
                  my source folder(ImageEffect in main.qml)?

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

                    qrc is meant for that, embed the file in your executable so your don't have to get them from your hard drive.

                    Note that it's not a "put in everything" solution. You can't take tones of megabytes and have them built in your executable (I am not saying it's your case, it's just a warning)

                    As for the qml side, I'm sorry but I have not yet any expertise with it. But IIRC there have been several post on the subject

                    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
                    • S Offline
                      S Offline
                      stereomatching
                      wrote on last edited by
                      #16

                      [quote author="SGaist" date="1372251293"]
                      As for the qml side, I'm sorry but I have not yet any expertise with it. But IIRC there have been several post on the subject[/quote]

                      Thanks for your replies, don't worry
                      I have no intent to make every thing become part of my
                      executeable, what I want to do is make sure the resource files
                      like shaders, icons and qml could be loaded without too much
                      headaches.

                      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