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

QML module Imports Not Found by IDE

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmlimportidewarningmodule
18 Posts 6 Posters 3.4k Views 3 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.
  • Axel SpoerlA Axel Spoerl

    import untitled tries to import something from the project's root directory. It doesn't find anything, because there's nothing to import, e.g. another QML file.
    Simply drop it and the warnings will disappear.

    GrecKoG Offline
    GrecKoG Offline
    GrecKo
    Qt Champions 2018
    wrote on last edited by
    #3

    @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.

    Axel SpoerlA 1 Reply Last reply
    0
    • Axel SpoerlA Axel Spoerl

      import untitled tries to import something from the project's root directory. It doesn't find anything, because there's nothing to import, e.g. another QML file.
      Simply drop it and the warnings will disappear.

      S Offline
      S Offline
      SimpleY
      wrote on last edited by SimpleY
      #4

      @Axel-Spoerl By drop I assume you mean delete the line? But the whole issue is about importing the main module which by default is named exactly as the project, here untitled as that's my project name. I am pretty sure the QML engine itself finds the module at runtime without issues because I explained the application builds & runs fine, so it's just the IDE as I see it and the code is fine too.

      @GrecKo So you think this is a bug too? I thought that originally but didn't dare to call it as such as I am a complete beginner in Qt to be honest. I will report it soon but https://bugreports.qt.io/secure/Dashboard.jspa doesn't work for me, says 503 Service Unavailable?

      1 Reply Last reply
      0
      • Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by
        #5

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

        Software Engineer
        The Qt Company, Oslo

        GrecKoG 1 Reply Last reply
        0
        • GrecKoG GrecKo

          @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.

          Axel SpoerlA Offline
          Axel SpoerlA Offline
          Axel Spoerl
          Moderators
          wrote on 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
          • Axel SpoerlA Axel Spoerl

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

            GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote on 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 ;)

            Axel SpoerlA 1 Reply Last reply
            0
            • GrecKoG Offline
              GrecKoG Offline
              GrecKo
              Qt Champions 2018
              wrote on 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
              0
              • GrecKoG GrecKo

                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 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
                • GrecKoG GrecKo

                  @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 ;)

                  Axel SpoerlA Offline
                  Axel SpoerlA Offline
                  Axel Spoerl
                  Moderators
                  wrote on 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

                  GrecKoG 1 Reply Last reply
                  0
                  • Axel SpoerlA Offline
                    Axel SpoerlA Offline
                    Axel Spoerl
                    Moderators
                    wrote on 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
                    • Axel SpoerlA Axel Spoerl

                      @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
                      GrecKoG Offline
                      GrecKoG Offline
                      GrecKo
                      Qt Champions 2018
                      wrote on 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 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
                        2
                        • S Sami Shalayel

                          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 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
                          • S Offline
                            S Offline
                            Sami Shalayel
                            wrote on 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
                            1
                            • S Sami Shalayel

                              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 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
                              • S Sami Shalayel

                                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 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 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

                                  • Login

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