Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    QML and Qt Quick
    qmlregistertype c++ to qml subdirectories subproject
    2
    4
    325
    Loading More Posts
    • 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
      Tee_ last edited by Tee_

      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.

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @Tee_ last edited by

        @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 Reply Quote 0
        • T
          Tee_ @raven-worx last edited by Tee_

          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 😓

          raven-worx 1 Reply Last reply Reply Quote 0
          • raven-worx
            raven-worx Moderators @Tee_ last edited by

            @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 Reply Quote 0
            • First post
              Last post