Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML files in resource of library not found in app using the library
Forum Updated to NodeBB v4.3 + New Features

QML files in resource of library not found in app using the library

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 1.1k Views 2 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.
  • N Offline
    N Offline
    Nando
    wrote on last edited by
    #1

    Hello friends,

    i have the following setup:

    mylib

    • mylib.qrc (containing QML and SVG)

    myapp

    • myapp.qrc (also containing QML and SVG)

    Now when i want to access a QML component which is located in the mylib.qrc from a QML compomnent which is in the myapp.qrc it is not known and i get the error "XXXX is not a type"

    What do i need to make that the QML components from the resource inside my lib (mylib.qrc) gets available to the applications QML components which uses the lib?
    I already tried Q_INIT_RESOURCE(mylib) in my main.cpp directly after QGuiApplication app(argc, argv) but it seems not to work...

    Thank's for your help :)

    Greetings
    Nando

    sierdzioS 1 Reply Last reply
    0
    • N Nando

      Hello friends,

      i have the following setup:

      mylib

      • mylib.qrc (containing QML and SVG)

      myapp

      • myapp.qrc (also containing QML and SVG)

      Now when i want to access a QML component which is located in the mylib.qrc from a QML compomnent which is in the myapp.qrc it is not known and i get the error "XXXX is not a type"

      What do i need to make that the QML components from the resource inside my lib (mylib.qrc) gets available to the applications QML components which uses the lib?
      I already tried Q_INIT_RESOURCE(mylib) in my main.cpp directly after QGuiApplication app(argc, argv) but it seems not to work...

      Thank's for your help :)

      Greetings
      Nando

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @Nando said in QML files in resource of library not found in app using the library:

      I already tried Q_INIT_RESOURCE(mylib) in my main.cpp directly after QGuiApplication app(argc, argv) but it seems not to work...

      It should work. Once a resource is loaded, QML engine does not care which QRC file the data is coming from.

      So I'd suggest first to make sure that Q_INIT_RESOURCE worked well - try opening some file from mylib.qrc in your main.cpp, using QFile.

      Second step is to make sure your prefix / path inside QRC is correct. Lastly, make sure there is no conflict for file you want to access (is the same file name registered in both QRC files?).

      Plus, of course, if your component is part of a QML module qmldir, you have to register it's import path with QML engine.

      (Z(:^

      N 1 Reply Last reply
      2
      • sierdzioS sierdzio

        @Nando said in QML files in resource of library not found in app using the library:

        I already tried Q_INIT_RESOURCE(mylib) in my main.cpp directly after QGuiApplication app(argc, argv) but it seems not to work...

        It should work. Once a resource is loaded, QML engine does not care which QRC file the data is coming from.

        So I'd suggest first to make sure that Q_INIT_RESOURCE worked well - try opening some file from mylib.qrc in your main.cpp, using QFile.

        Second step is to make sure your prefix / path inside QRC is correct. Lastly, make sure there is no conflict for file you want to access (is the same file name registered in both QRC files?).

        Plus, of course, if your component is part of a QML module qmldir, you have to register it's import path with QML engine.

        N Offline
        N Offline
        Nando
        wrote on last edited by Nando
        #3

        @sierdzio Hi and thank you.
        I tested it with opening a file inside the mylib.qrc from my app using QFile and it works fine.

        But every time a QML component from myapp.qrc tries to use a component from mylib.qrc i still get the error 'xxx is not a type'

        No duplicate file names.

        What do you mean with:
        Plus, of course, if your component is part of a QML module qmldir, you have to register it's import path with QML engine?

        I just have a qml directory in my lib root dir and a qml directory in my app root dir.
        Each (lib and app) has its own .qrc file referencing the QML files from theire qml directory...

        It would be really nice if you could help me a bit further.

        Thank you :)

        Nando

        sierdzioS 1 Reply Last reply
        0
        • N Nando

          @sierdzio Hi and thank you.
          I tested it with opening a file inside the mylib.qrc from my app using QFile and it works fine.

          But every time a QML component from myapp.qrc tries to use a component from mylib.qrc i still get the error 'xxx is not a type'

          No duplicate file names.

          What do you mean with:
          Plus, of course, if your component is part of a QML module qmldir, you have to register it's import path with QML engine?

          I just have a qml directory in my lib root dir and a qml directory in my app root dir.
          Each (lib and app) has its own .qrc file referencing the QML files from theire qml directory...

          It would be really nice if you could help me a bit further.

          Thank you :)

          Nando

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @Nando said in QML files in resource of library not found in app using the library:

          I just have a qml directory in my lib root dir and a qml directory in my app root dir.
          Each (lib and app) has its own .qrc file referencing the QML files from theire qml directory...

          OK, please post some of the QRC code (from both .qrcs) here, as well as the import statements from QML and how you call the component which fails to load. My guess is that some import is missing, or wrong path is provided, or something similar - but without concrete data it's hard to say anything specific.

          (Z(:^

          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