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. Ambiguous project when using files in subdirectory
Forum Updated to NodeBB v4.3 + New Features

Ambiguous project when using files in subdirectory

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qml cmake
8 Posts 2 Posters 67 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.
  • D Offline
    D Offline
    DoktorNik
    wrote last edited by DoktorNik
    #1

    I'm trying to keep my files in separate subdirectories so that things are more organized and easier to manage than when dumping everything in the root directory.

    The resources and sources work fine, but I'm having a lot of problems getting QML to work properly with this approach.

    When the files are in the root directory the project runs fine:

    qt_add_qml_module(appMyProject
        URI MyProject
        VERSION 1.0
        QML_FILES
            Main.qml
            PlanetList.qml
            NumberFormatter.js
    )
    

    but when I try to use them in subdirectories, things no longer work

    qt_add_qml_module(appMyProject
        URI MyProject
        VERSION 1.0
        QML_FILES
            Main.qml
            src/qml/PlanetList.qml
            src/qml/NumberFormatter.js
    

    The error I get is:
    warning: qrc:/qt/qml/MyProject/src/qml/PlanetList.qml: "MyProject" is ambiguous. Found in qrc:/qt/qml/MyProject/ and in qrc:/qt/qml/MyProject/

    I'm not sure what's going on as according to this message it seems it can't tell the difference between itself and itself.

    How can I troubleshoot this or get it to work properly?

    Thanks

    JKSHJ 1 Reply Last reply
    0
    • D DoktorNik

      I'm trying to keep my files in separate subdirectories so that things are more organized and easier to manage than when dumping everything in the root directory.

      The resources and sources work fine, but I'm having a lot of problems getting QML to work properly with this approach.

      When the files are in the root directory the project runs fine:

      qt_add_qml_module(appMyProject
          URI MyProject
          VERSION 1.0
          QML_FILES
              Main.qml
              PlanetList.qml
              NumberFormatter.js
      )
      

      but when I try to use them in subdirectories, things no longer work

      qt_add_qml_module(appMyProject
          URI MyProject
          VERSION 1.0
          QML_FILES
              Main.qml
              src/qml/PlanetList.qml
              src/qml/NumberFormatter.js
      

      The error I get is:
      warning: qrc:/qt/qml/MyProject/src/qml/PlanetList.qml: "MyProject" is ambiguous. Found in qrc:/qt/qml/MyProject/ and in qrc:/qt/qml/MyProject/

      I'm not sure what's going on as according to this message it seems it can't tell the difference between itself and itself.

      How can I troubleshoot this or get it to work properly?

      Thanks

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

      Hi, and welcome!

      @DoktorNik said in Ambiguous project when using files in subdirectory:

      How can I troubleshoot this or get it to work properly?

      You might be encountering one of these bugs:

      • https://bugreports.qt.io/browse/QTBUG-133587
      • https://bugreports.qt.io/browse/QTBUG-138391

      Upgrade to Qt 6.10.0-beta2. Does it work now?

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

      D 1 Reply Last reply
      0
      • JKSHJ JKSH

        Hi, and welcome!

        @DoktorNik said in Ambiguous project when using files in subdirectory:

        How can I troubleshoot this or get it to work properly?

        You might be encountering one of these bugs:

        • https://bugreports.qt.io/browse/QTBUG-133587
        • https://bugreports.qt.io/browse/QTBUG-138391

        Upgrade to Qt 6.10.0-beta2. Does it work now?

        D Offline
        D Offline
        DoktorNik
        wrote last edited by
        #3

        @JKSH Thanks for the reply and pointing out those bug reports. I verified that the problem has to do with the .js files

        I'm still pretty new to Qt so maybe I'm missing something simple, but I couldn't get the beta version to build on my MacBook.

        The readme says:

        Linux, Mac:
        -----------
        cd <path>/<source_package>
        ./configure -prefix $PWD/qtbase
        cmake --build .
        

        but it fails being unable to find something

        ./configure -prefix $PWD/qtbase
        + /Users/niko/Downloads/qt6.10.build2/qtbase/configure -top-level -prefix /Users/niko/Downloads/qt6.10.build2/qtbase
        CMake Error at cmake/QtIRProcessHelpers.cmake:173 (message):
          /Users/niko/Downloads/qt6.10.build2/qtbase/configure -top-level -prefix
          /Users/niko/Downloads/qt6.10.build2/qtbase exited with status: no such file
          or directory
        
        Call Stack (most recent call first):
          cmake/QtTopLevelHelpers.cmake:35 (qt_ir_execute_process_and_log_and_handle_error)
          cmake/QtTopLevelHelpers.cmake:57 (qt_tl_run_toplevel_configure)
          cmake/QtTopLevelConfigureScript.cmake:16 (qt_tl_run_main_script)
        

        Any further advice?

        JKSHJ 1 Reply Last reply
        0
        • D DoktorNik

          @JKSH Thanks for the reply and pointing out those bug reports. I verified that the problem has to do with the .js files

          I'm still pretty new to Qt so maybe I'm missing something simple, but I couldn't get the beta version to build on my MacBook.

          The readme says:

          Linux, Mac:
          -----------
          cd <path>/<source_package>
          ./configure -prefix $PWD/qtbase
          cmake --build .
          

          but it fails being unable to find something

          ./configure -prefix $PWD/qtbase
          + /Users/niko/Downloads/qt6.10.build2/qtbase/configure -top-level -prefix /Users/niko/Downloads/qt6.10.build2/qtbase
          CMake Error at cmake/QtIRProcessHelpers.cmake:173 (message):
            /Users/niko/Downloads/qt6.10.build2/qtbase/configure -top-level -prefix
            /Users/niko/Downloads/qt6.10.build2/qtbase exited with status: no such file
            or directory
          
          Call Stack (most recent call first):
            cmake/QtTopLevelHelpers.cmake:35 (qt_ir_execute_process_and_log_and_handle_error)
            cmake/QtTopLevelHelpers.cmake:57 (qt_tl_run_toplevel_configure)
            cmake/QtTopLevelConfigureScript.cmake:16 (qt_tl_run_main_script)
          

          Any further advice?

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

          @DoktorNik You're welcome! I suggest installing the beta using the Qt Online Installer (which becomes the MaintenanceTool after you've run the installer). No need to build it from source

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

          D 1 Reply Last reply
          0
          • JKSHJ JKSH

            @DoktorNik You're welcome! I suggest installing the beta using the Qt Online Installer (which becomes the MaintenanceTool after you've run the installer). No need to build it from source

            D Offline
            D Offline
            DoktorNik
            wrote last edited by
            #5

            @JKSH I installed the 6.10.0-beta2 version with the installer/maintenance tool.

            Then I cleared the cmake config, removed the build directory, reran cmake, and rebuilt.

            Unfortunately, it is the same problem. So long as the .js file is under QML_FILES in qt_add_qml_module, the app doesn't run.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DoktorNik
              wrote last edited by
              #6

              Actually, it seems to have made it worse as now I get the ambiguous error even when the .js file is in the root directory.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DoktorNik
                wrote last edited by DoktorNik
                #7

                It seems to run properly when I include this line in my cmake file:

                # workaround for bug with javascript files
                qt_policy(SET QTP0004 OLD)
                

                Thanks for pointing me in the right direction

                JKSHJ 1 Reply Last reply
                0
                • D DoktorNik

                  It seems to run properly when I include this line in my cmake file:

                  # workaround for bug with javascript files
                  qt_policy(SET QTP0004 OLD)
                  

                  Thanks for pointing me in the right direction

                  JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote last edited by
                  #8

                  @DoktorNik Thanks for sharing your workaround. I'm glad to hear that you got it working.

                  Thanks also for writing up a detailed bug report: https://bugreports.qt.io/browse/QTBUG-139233 It looks like the "Fix Version(s)" field for QTBUG-138391 was incorrect, and Qt 6.10.0-beta2 still contains the bug. You should be able to remove your workaround once Qt 6.9.2 or 6.10.0 are released.

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

                  1 Reply Last reply
                  1

                  • Login

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