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 Imports Not Found by IDE

QML module Imports Not Found by IDE

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmlimportidewarningmodule
18 Posts 6 Posters 3.1k 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.
  • A Offline
    A Offline
    Axel Spoerl
    Moderators
    wrote on 22 Oct 2024, 23:55 last edited by
    #5

    @SimpleY
    untitled contains nothing but Main.qml here. Why should Main.qml import itself?

    Software Engineer
    The Qt Company, Oslo

    G 1 Reply Last reply 23 Oct 2024, 07:55
    0
    • G GrecKo
      22 Oct 2024, 21:01

      @Axel-Spoerl hum ? import untitled tries to import the untitled module. There's no directory involved, at least not directly. Even with another file in the module, Qt C would complain.

      @SimpleY I'd suggest reporting this as an issue on https://bugreports.qt.io/secure/Dashboard.jspa , please post the link here after so we can follow.

      A Offline
      A Offline
      Axel Spoerl
      Moderators
      wrote on 23 Oct 2024, 05:25 last edited by
      #6

      @GrecKo said in QML module Imports Not Found by IDE:

      Even with another file in the module, Qt C would complain.

      No, it clearly doesn't.

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      0
      • A Axel Spoerl
        22 Oct 2024, 23:55

        @SimpleY
        untitled contains nothing but Main.qml here. Why should Main.qml import itself?

        G Offline
        G Offline
        GrecKo
        Qt Champions 2018
        wrote on 23 Oct 2024, 07:55 last edited by GrecKo
        #7

        @Axel-Spoerl said in QML module Imports Not Found by IDE:

        @SimpleY
        untitled contains nothing but Main.qml here. Why should Main.qml import itself?

        There's no particular reason to import it here, but it should still be possible.
        The import working is not subject to it being useful...

        @Axel-Spoerl said in QML module Imports Not Found by IDE:

        No, it clearly doesn't.

        Have you tried? I tried and it clearly does complain.
        I've followed OP repro steps and added another QML file in the module and even went as far as using it in Main.qml so the import would be useful ;)

        A 1 Reply Last reply 23 Oct 2024, 10:37
        0
        • G Offline
          G Offline
          GrecKo
          Qt Champions 2018
          wrote on 23 Oct 2024, 08:19 last edited by
          #8

          Building the project fixes the issue though (with or without another file).
          If you don't actually use a type of the new module Qt Creator will complain about the "Unused import" but that's expected.

          S 1 Reply Last reply 23 Oct 2024, 10:12
          0
          • G GrecKo
            23 Oct 2024, 08:19

            Building the project fixes the issue though (with or without another file).
            If you don't actually use a type of the new module Qt Creator will complain about the "Unused import" but that's expected.

            S Offline
            S Offline
            SimpleY
            wrote on 23 Oct 2024, 10:12 last edited by
            #9

            @GrecKo For me nothing changes when I build it, the warnings remain the exact same. I also tried to do Tools > QML > Reset Codebade but it doesn't help. I could well imagine that this is just a bug in the newest version of Qt Creator or Qt framework, do you have the same environment as me installed?

            1 Reply Last reply
            0
            • G GrecKo
              23 Oct 2024, 07:55

              @Axel-Spoerl said in QML module Imports Not Found by IDE:

              @SimpleY
              untitled contains nothing but Main.qml here. Why should Main.qml import itself?

              There's no particular reason to import it here, but it should still be possible.
              The import working is not subject to it being useful...

              @Axel-Spoerl said in QML module Imports Not Found by IDE:

              No, it clearly doesn't.

              Have you tried? I tried and it clearly does complain.
              I've followed OP repro steps and added another QML file in the module and even went as far as using it in Main.qml so the import would be useful ;)

              A Offline
              A Offline
              Axel Spoerl
              Moderators
              wrote on 23 Oct 2024, 10:37 last edited by
              #10

              @GrecKo said in QML module Imports Not Found by IDE:

              Have you tried? I tried and it clearly does complain.

              Sure thing, I am doing that every day. But of course I never try to import a project containing nothing but its own Main.qml.
              The issue here starts by including something that doesn't need to be included - and therefore shouldn't be.
              The warnings disappear in the following cases:

              • project contains something worth including, e.g. a QML extension written in C++
              • unnecessary include statement is removed

              The warning says "Failed to import untitled". To me, that's clear: Either there's nothing to import at all, or the import of something existing failed. It could be a suggestion in our bug tracker, to emit separate warnings:

              • Nothing to import
              • Failed to import (there is something

              Software Engineer
              The Qt Company, Oslo

              G 1 Reply Last reply 23 Oct 2024, 11:55
              0
              • A Offline
                A Offline
                Axel Spoerl
                Moderators
                wrote on 23 Oct 2024, 10:54 last edited by Axel Spoerl
                #11

                You can have a look at the FX_Material_Showroom example to see how import syntax works.
                Also look at this Jira ticket for reference.

                Software Engineer
                The Qt Company, Oslo

                1 Reply Last reply
                0
                • A Axel Spoerl
                  23 Oct 2024, 10:37

                  @GrecKo said in QML module Imports Not Found by IDE:

                  Have you tried? I tried and it clearly does complain.

                  Sure thing, I am doing that every day. But of course I never try to import a project containing nothing but its own Main.qml.
                  The issue here starts by including something that doesn't need to be included - and therefore shouldn't be.
                  The warnings disappear in the following cases:

                  • project contains something worth including, e.g. a QML extension written in C++
                  • unnecessary include statement is removed

                  The warning says "Failed to import untitled". To me, that's clear: Either there's nothing to import at all, or the import of something existing failed. It could be a suggestion in our bug tracker, to emit separate warnings:

                  • Nothing to import
                  • Failed to import (there is something
                  G Offline
                  G Offline
                  GrecKo
                  Qt Champions 2018
                  wrote on 23 Oct 2024, 11:55 last edited by GrecKo
                  #12

                  @Axel-Spoerl said in QML module Imports Not Found by IDE:

                  The warning says "Failed to import untitled". To me, that's clear: Either there's nothing to import at all, or the import of something existing failed. It could be a suggestion in our bug tracker, to emit separate warnings:

                  • Nothing to import
                  • Failed to import (there is something

                  The first point is incorrect, the warning is there even when there's something to import (and even used).
                  And not having something else but Main.qml wouldn't warrant this. The module is there to import. The language server doesn't evaluate if a module is worth importing before importing, it just imports it. As confirmed by Qt Creator initially complaining but not after a build on my system with only Main.qml in the module (note that a clean reintroduces the warning).

                  @SimpleY said in QML module Imports Not Found by IDE:

                  @GrecKo For me nothing changes when I build it, the warnings remain the exact same. I also tried to do Tools > QML > Reset Codebade but it doesn't help. I could well imagine that this is just a bug in the newest version of Qt Creator or Qt framework, do you have the same environment as me installed?

                  I am also using Qt C 14.0.2 and Qt 6.8.0 but on Linux with GCC.
                  I do think this is worthy of a bug report, not sure if it will be high priority though. (EDIT: Axel mentioned this thread in the relevant Jira ticket, it is closed though).

                  1 Reply Last reply
                  1
                  • S Offline
                    S Offline
                    Sami Shalayel
                    wrote on 23 Oct 2024, 13:14 last edited by
                    #13

                    Hello! From a quick look, it seems that your qmlls is not setup correctly and therefore can't find untitled. Could you try following steps and see if they resolve your issue?

                    1. Pass the build folder to qmlls: you can do this via a variety of options (https://doc.qt.io/qt-6/qtqml-tooling-qmlls.html#setting-up-the-qml-language-server-in-your-editor) but I recommend setting the QT_QML_GENERATE_QMLLS_INI CMake variable to ON.
                    2. Build the project: that generates the qmldir files etc (via the qt_add_qml_module) that qmlls needs to detect QML modules (and the .qmlls.ini files if you set QT_QML_GENERATE_QMLLS_INI to ON in the previous step)
                    3. Restart the language server (using the language server button in the toolbar right above the QML text editor
                      image.png )
                    S T 2 Replies Last reply 23 Oct 2024, 15:22
                    2
                    • S Sami Shalayel
                      23 Oct 2024, 13:14

                      Hello! From a quick look, it seems that your qmlls is not setup correctly and therefore can't find untitled. Could you try following steps and see if they resolve your issue?

                      1. Pass the build folder to qmlls: you can do this via a variety of options (https://doc.qt.io/qt-6/qtqml-tooling-qmlls.html#setting-up-the-qml-language-server-in-your-editor) but I recommend setting the QT_QML_GENERATE_QMLLS_INI CMake variable to ON.
                      2. Build the project: that generates the qmldir files etc (via the qt_add_qml_module) that qmlls needs to detect QML modules (and the .qmlls.ini files if you set QT_QML_GENERATE_QMLLS_INI to ON in the previous step)
                      3. Restart the language server (using the language server button in the toolbar right above the QML text editor
                        image.png )
                      S Offline
                      S Offline
                      SimpleY
                      wrote on 23 Oct 2024, 15:22 last edited by
                      #14

                      @Sami-Shalayel Oh my god thank you so much! This really worked like a charm, now I only get this warning but I am well aware that this is normal now...
                      136f3d35-b7d6-49aa-9757-f6b414471e24-image.png
                      All I had to do as you said is add set(QT_QML_GENERATE_QMLLS_INI ON) in the CMake file and rebuild.

                      So in the future I just have to set QT_QML_GENERATE_QMLLS_INI to ON in all of my projects or should I try to fix it another way?

                      1 Reply Last reply
                      0
                      • S SimpleY has marked this topic as solved on 23 Oct 2024, 20:38
                      • S Offline
                        S Offline
                        Sami Shalayel
                        wrote on 24 Oct 2024, 08:34 last edited by
                        #15

                        If it works for you then Qt Creator can set it for you automatically on new projects if you check the checkbox at Preferences > Qt Quick > QML/JS Editing > Create .qmlls.ini files for new projects (see also https://doc.qt.io/qtcreator/creator-how-to-use-qml-language-server.html ). Its currently not checked by default because the current solution currently does not satisfy everyone (some people can't have .qmlls.ini files generated in their source folder for example), but there will be a solution to make it work out of the box in qt creator in the future.

                        S 1 Reply Last reply 24 Oct 2024, 11:12
                        1
                        • S Sami Shalayel
                          24 Oct 2024, 08:34

                          If it works for you then Qt Creator can set it for you automatically on new projects if you check the checkbox at Preferences > Qt Quick > QML/JS Editing > Create .qmlls.ini files for new projects (see also https://doc.qt.io/qtcreator/creator-how-to-use-qml-language-server.html ). Its currently not checked by default because the current solution currently does not satisfy everyone (some people can't have .qmlls.ini files generated in their source folder for example), but there will be a solution to make it work out of the box in qt creator in the future.

                          S Offline
                          S Offline
                          SimpleY
                          wrote on 24 Oct 2024, 11:12 last edited by
                          #16

                          @Sami-Shalayel Hey, thank you again! That option is quite useful for new projects.

                          If it's not too much to ask can you please also check out this issue since you seem to be familiar with QMLLS?

                          1 Reply Last reply
                          0
                          • S SimpleY has marked this topic as solved on 25 Oct 2024, 11:23
                          • S Sami Shalayel
                            23 Oct 2024, 13:14

                            Hello! From a quick look, it seems that your qmlls is not setup correctly and therefore can't find untitled. Could you try following steps and see if they resolve your issue?

                            1. Pass the build folder to qmlls: you can do this via a variety of options (https://doc.qt.io/qt-6/qtqml-tooling-qmlls.html#setting-up-the-qml-language-server-in-your-editor) but I recommend setting the QT_QML_GENERATE_QMLLS_INI CMake variable to ON.
                            2. Build the project: that generates the qmldir files etc (via the qt_add_qml_module) that qmlls needs to detect QML modules (and the .qmlls.ini files if you set QT_QML_GENERATE_QMLLS_INI to ON in the previous step)
                            3. Restart the language server (using the language server button in the toolbar right above the QML text editor
                              image.png )
                            T Offline
                            T Offline
                            Tick info
                            wrote on 15 Nov 2024, 11:54 last edited by
                            #17

                            @Sami-Shalayel
                            hello ! I have been facing the same issue but I am using mac m4 and I tried what you mentioned in the comment. but it does not work.
                            android architecture arm64v8a
                            qt creator 6.8.0
                            qt version same as mentioned in the problem.
                            using "qmlRegisterType" to link the qt but as the problem says its throw warning and autocompletion is also not working.

                            the same thing properly working in qt 6.7.2 but not in latest version

                            guide me if you have solution.

                            1 Reply Last reply
                            0
                            • L Offline
                              L Offline
                              Lazyplayer
                              wrote on 20 Nov 2024, 08:14 last edited by
                              #18

                              @SimpleY i ve got same problem as your, try to go to preferences->Qt Quick->QML/JS editing-> QML Language server and remove tick on Tun on (leave all unchecked)

                              it worked for me.

                              1 Reply Last reply
                              0

                              14/18

                              23 Oct 2024, 15:22

                              • Login

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