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 Module not found | QML_ELEMENT | Working with separate sub-projects

QML Module not found | QML_ELEMENT | Working with separate sub-projects

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlregistertypec++ to qmlsubdirectoriessubproject
4 Posts 2 Posters 837 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.
  • T Offline
    T Offline
    Tee_
    wrote on 30 Nov 2021, 19:40 last edited by Tee_ 12 Jan 2021, 06:11
    #1

    I have the following project structure:

    MyApp
    | - MyApp.pro
    | - MyAppUi
    | - MyAppUi.pro
    | - MyAppLib
    | - MyAppLib.pro

    MyAppUi contains qml files, and MyAppLib contains c++ files. These two are separate sub-projects with their own .proj files, and they both live under the MyApp parent dir.

    I previously had c++ files in MyAppUi that I exposed using QML_ELEMENT to qml. The QML_IMPORT_NAME declarations were under the MyAppUi .pro file. The system worked fine and was able to detect the module.

    I have now moved the c++ files to the MyAppLib directory, and the QML_IMPORT_NAME declarations are now under the MyAppLib .pro file. MyAppUi is now no longer picking up the module.

    What do I need to configure to expose the c++ types declared in a different sub project/directory (MyAppLib) to MyAppUi? I just need to detect the module name.

    This is probably a trivial issues but I've been on it for the past two days and haven't had a breakthrough. Please help.

    R 1 Reply Last reply 30 Nov 2021, 19:56
    0
    • T Tee_
      30 Nov 2021, 19:40

      I have the following project structure:

      MyApp
      | - MyApp.pro
      | - MyAppUi
      | - MyAppUi.pro
      | - MyAppLib
      | - MyAppLib.pro

      MyAppUi contains qml files, and MyAppLib contains c++ files. These two are separate sub-projects with their own .proj files, and they both live under the MyApp parent dir.

      I previously had c++ files in MyAppUi that I exposed using QML_ELEMENT to qml. The QML_IMPORT_NAME declarations were under the MyAppUi .pro file. The system worked fine and was able to detect the module.

      I have now moved the c++ files to the MyAppLib directory, and the QML_IMPORT_NAME declarations are now under the MyAppLib .pro file. MyAppUi is now no longer picking up the module.

      What do I need to configure to expose the c++ types declared in a different sub project/directory (MyAppLib) to MyAppUi? I just need to detect the module name.

      This is probably a trivial issues but I've been on it for the past two days and haven't had a breakthrough. Please help.

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 30 Nov 2021, 19:56 last edited by
      #2

      @Tee_
      i am not 100% sure if i understand what you are trying to do or because you need the import name in another project.
      but move it to a .pri file and include it in both projects

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      T 1 Reply Last reply 1 Dec 2021, 06:10
      0
      • R raven-worx
        30 Nov 2021, 19:56

        @Tee_
        i am not 100% sure if i understand what you are trying to do or because you need the import name in another project.
        but move it to a .pri file and include it in both projects

        T Offline
        T Offline
        Tee_
        wrote on 1 Dec 2021, 06:10 last edited by Tee_ 12 Jan 2021, 06:16
        #3

        Hello @raven-worx

        My issue was that when I was trying to define the module in the MyAppUi.pro file, the system was not picking up the c++ files with QML_ELEMENT in the MyAppLib project. I specified the import path but it was still not picking them up and registering them.

        So I moved the module declaration to MyAppLib.pro and tried importing it in the qml files in MyAppUi, but the module could not be detected. Maybe what I was trying to do didn't make sense anyway, idk.

        I just reverted to the older way of registering the types with qmlRegisterType.

        Bleh 😓

        R 1 Reply Last reply 1 Dec 2021, 08:54
        0
        • T Tee_
          1 Dec 2021, 06:10

          Hello @raven-worx

          My issue was that when I was trying to define the module in the MyAppUi.pro file, the system was not picking up the c++ files with QML_ELEMENT in the MyAppLib project. I specified the import path but it was still not picking them up and registering them.

          So I moved the module declaration to MyAppLib.pro and tried importing it in the qml files in MyAppUi, but the module could not be detected. Maybe what I was trying to do didn't make sense anyway, idk.

          I just reverted to the older way of registering the types with qmlRegisterType.

          Bleh 😓

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 1 Dec 2021, 08:54 last edited by
          #4

          @Tee_
          normally a pro file results in a separate target (executable or library). Even if you "combine" them with a subdirs project.
          So your AppUi project must link against the AppLib

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0

          4/4

          1 Dec 2021, 08:54

          • Login

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