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. module importation problem
Forum Updated to NodeBB v4.3 + New Features

module importation problem

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 2 Posters 1.5k 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by mzimmers
    #1

    Hi all -

    I'm looking at an app with nested CMakeLists.txt files. The other developers are using VS Code to build this app, partly because they couldn't get Creator to work properly. Specifically, when the top-level CMake file is opened, Creator can't find one of our QML modules:

    cantfind.PNG

    Strangely enough, when I open one of the subordinate CMake files, the problem doesn't occur:

    found.PNG

    I'm assuming this works because of this line in the CMake file:

    list(APPEND QML_IMPORT_PATH ${CMAKE_SOURCE_DIR}/../libstyles)
    

    But what I don't understand is, why is this showing as unfound when I open the top-level CMake file?

    This is 5.14.2, BTW. Thanks for any ideas...

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Qt Creator so often does not see imported modules that I'm usually surprised when it works ;-)

      I have a few hints, but if they will help - no idea:

      • add libstyles to QML_IMPORT_PATH in the top-level cmake file
      • go to Tools->QML/JS->Reset Code Model this forces QtC to reparse files and refresh it's internal state - it sometimes helps in such situations
      • make sure you're using the newest Qt Creator and newest CMake

      (Z(:^

      mzimmersM 1 Reply Last reply
      1
      • sierdzioS sierdzio

        Qt Creator so often does not see imported modules that I'm usually surprised when it works ;-)

        I have a few hints, but if they will help - no idea:

        • add libstyles to QML_IMPORT_PATH in the top-level cmake file
        • go to Tools->QML/JS->Reset Code Model this forces QtC to reparse files and refresh it's internal state - it sometimes helps in such situations
        • make sure you're using the newest Qt Creator and newest CMake
        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by mzimmers
        #3

        @sierdzio thank you for the suggestions. I attempted to use the existing maintenance tool, and found to my surprise that there are no default repositories.

        I've never had to add a repository before. Any idea what's going on here?

        EDIT:

        Anyway, I've downloaded 5.15.2 (had been using 5.14.2) and the newest Creator. Still getting the error. And what's really strange is, when I open the libstyles CMake file, the error goes away:

        found.PNG

        (The open file is within src/lib/libresources.qrc/qml; I didn't expand that folder because I wanted to show its relation to libstyles.)

        Anyone have an idea on this? Thanks...

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @mzimmers said in module importation problem:

          Anyway, I've downloaded 5.15.2 (had been using 5.14.2) and the newest Creator.

          You can also download newest CMake using Qt Maintenance Tool, that's what I recommended actually.

          And what's really strange is, when I open the libstyles CMake file, the error goes away

          Ah, I think I've seen a similar behaviour. The workaround I use is this - each time I turn Qt Creator on, I right-click on project title (in left side pane) and select "Run CMake". This refreshes Qt Creator's cmake cache and stuff and it becomes suddenly more aware of the code.

          (Z(:^

          mzimmersM 1 Reply Last reply
          1
          • sierdzioS sierdzio

            @mzimmers said in module importation problem:

            Anyway, I've downloaded 5.15.2 (had been using 5.14.2) and the newest Creator.

            You can also download newest CMake using Qt Maintenance Tool, that's what I recommended actually.

            And what's really strange is, when I open the libstyles CMake file, the error goes away

            Ah, I think I've seen a similar behaviour. The workaround I use is this - each time I turn Qt Creator on, I right-click on project title (in left side pane) and select "Run CMake". This refreshes Qt Creator's cmake cache and stuff and it becomes suddenly more aware of the code.

            mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #5

            @sierdzio I had in fact downloaded CMake 3.19.2 (forgot to mention this). Unfortunately, your workaround doesn't seem to work for me. I even tried running the CMake for src/lib and src/libstyles; no change.

            I'm still trying to understand why opening the src/lib CMake project causes the error to go away. What might be happening when I open this project explicitly, that isn't happening when I open only the top-level project?

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              I don't know, sorry.

              (Z(:^

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                @mzimmers said in module importation problem:

                QML_IMPORT_PATH

                Actually, one more idea. Try setting correct path for QML_IMPORT_PATH in Project->Build in Qt Creator. I won't solve this for other developers but it might work on when set locally.

                (Z(:^

                mzimmersM 1 Reply Last reply
                0
                • sierdzioS sierdzio

                  @mzimmers said in module importation problem:

                  QML_IMPORT_PATH

                  Actually, one more idea. Try setting correct path for QML_IMPORT_PATH in Project->Build in Qt Creator. I won't solve this for other developers but it might work on when set locally.

                  mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by mzimmers
                  #8

                  @sierdzio I think you're on to something here (though I haven't fixed it yet). In looking at the build settings, it appears that the QML_IMPORT_PATH variable is populated by this line in build/CMakeCache.txt:

                  QML_IMPORT_PATH:STRING=/home/mzimmers/git/KOL-UI/qml;/home/mzimmers/git/KOL-UI/qml/dummydata;/home/mzimmers/git/KOL-UI/qml/priming;/home/mzimmers/git/KOL-UI/qml/running_synth;/home/mzimmers/git/KOL-UI/../libstyles;/home/mzimmers/git/KOL-UI/../libstyles/imports;/home/mzimmers/git/KOL-UI/../libstyles/imports/libstyles;/home/mzimmers/git/KOL-UI/build/bin;/home/mzimmers/git/KOL-UI/build/imports;/home/mzimmers/git/KOL-UI/build/bin;/home/mzimmers/git/KOL-UI/build/imports;/home/mzimmers/git/KOL-UI/build/imports
                  

                  I replaced a few entries to what I believe are correct paths:

                  QML_IMPORT_PATH:STRING=/home/mzimmers/git/KOL-UI/qml;/home/mzimmers/git/KOL-UI/qml/dummydata;/home/mzimmers/git/KOL-UI/qml/priming;/home/mzimmers/git/KOL-UI/qml/running_synth;/home/mzimmers/git/KOL-UI/src/libstyles;/home/mzimmers/git/KOL-UI/src/libstyles/imports;/home/mzimmers/git/KOL-UI/src/libstyles/imports/libstyles;/home/mzimmers/git/KOL-UI/build/bin;/home/mzimmers/git/KOL-UI/build/imports;/home/mzimmers/git/KOL-UI/build/bin;/home/mzimmers/git/KOL-UI/build/imports;/home/mzimmers/git/KOL-UI/build/imports
                  

                  And I re-ran CMake, but this didn't solve the problem. I went ahead and manually changed the build settings, and this did solve the problem, though I imagine the next time I do whatever causes the CMakeCache.txt file to be re-read will wipe out those changes.

                  EDIT:

                  So, with the help of someone in the office, we figured out what to do here. This line (among others) was in the subordinate CMake file; we just moved it to the root CMake file:

                  list(APPEND QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/libstyles)
                  

                  I'm not sure it was necessary to use CMAKE_CURRENT_SOURCE_DIR instead of CMAKE_SOURCE_DIR in this instance, but it's probably a good practice.

                  Thanks for the help...

                  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