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. plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...
Forum Updated to NodeBB v4.3 + New Features

plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
11 Posts 5 Posters 3.8k 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.
  • A Offline
    A Offline
    alex_malyu
    wrote on last edited by alex_malyu
    #1

    Installed Qt 5.15.2 with MinGW (32 and 64)

    It works until I start importing QtQuick.Layouts and QtQuick.Controls
    Debugging in QtCreator fails with:

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Layouts 2.15
    import QtQuick.Controls 2.15

    In the meantime import is visible in QtCreator, if I remove import appropriate components are marked as not found.
    Error looks like:

    QQmlApplicationEngine failed to load component
    qrc:/main.qml:3:1: plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered
    QML debugging is enabled. Only use this in a safe environment.

    I've seen the closed bug on similar issue.
    I updated the qt today.
    Nothing changed.

    Anybody knows workaround?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on last edited by
      #2

      It seems bug was either re-introduced or never was fixed:

      https://bugreports.qt.io/browse/QTBUG-81961?jql=text ~ "Cannot protect module QtQuick.Controls 2"

      That's fixed by https://codereview.qt-project.org/c/qt/qtquickcontrols2/+/289223 but is prevented from getting in due to QTBUG-81772, which has a blacklist patch but another part of the test apparently crashes once the tests are blacklisted... ugh.
      I think we can close this in any case.

      I think closing critical bugs without having them pushed to repo is a bad choice.

      In any case I need workaround, It is impossible to develop anything.
      How does it work with other systems?

      I used Qt 5.9.5 on Ubuntu, but need newer version now. Anybody can share which one works on Windows with MinGW?

      JKSHJ 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        The bug mentions Qt 6 and from the comments it has been fixed there.

        If you have the same issue, you should comment on the bug report.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        RokeJulianLockhartR 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          The bug mentions Qt 6 and from the comments it has been fixed there.

          If you have the same issue, you should comment on the bug report.

          RokeJulianLockhartR Offline
          RokeJulianLockhartR Offline
          RokeJulianLockhart
          wrote last edited by RokeJulianLockhart
          #4

          If you have the same issue, you should comment on the bug report.

          @SGaist, That issue appears to have been closed for a reason I don't understand. However, I've the same problem:

          #!/usr/bin/env -S qml
          import QtQuick 6.9
          import QtQuick.Controls 6.9
          import QtQuick.Layouts 6.9
          ApplicationWindow {
          	visible: true
          	title: qsTr("Application Menu")
          	RowLayout {
          		anchors.centerIn: parent
          		spacing: 10
          		Label {
          			text: "Hello from QML!"
          		}
          		Button {
          			text: "Click Me"
          			onClicked: console.log("Button clicked")
          		}
          	}
          }
          
          

          When I invoke this with qml $HOME/main.qml, I see "Cannot protect module QtQuick.Controls 6 as it was never registered":

          QQmlApplicationEngine failed to load component
          file:///home/RokeJulianLockhart/Documents/main.qml:3:1: plugin cannot be loaded for module "QtQuick.Controls": Cannot protect module QtQuick.Controls 6 as it was never registered
          qml: Did not load any objects, exiting.
          

          If I modify it to be more minimal:

          #!/usr/bin/env -S qml
          import QtQuick 6.9
          ApplicationWindow {
          	visible: true
          	title: qsTr("Application Menu")
          }
          
          

          ...I see:

          main.qml:2:1: module "QtQuick" is not installed

          This shouldn't be possible, because kinfo returns "Qt Version: 6.9.1":

          Operating System: Fedora Linux 42
          KDE Plasma Version: 6.4.4
          KDE Frameworks Version: 6.17.0
          Qt Version: 6.9.1
          Kernel Version: 6.15.9-201.fc42.x86_64 (64-bit)
          Graphics Platform: Wayland
          

          Additionally, if I invoke at least the former version via Python, it works:

          1. #!/usr/bin/env -S python3
            import sys
            from PySide6.QtCore import QUrl
            from PySide6.QtGui import QGuiApplication
            from PySide6.QtQml import QQmlApplicationEngine
            if __name__ == "__main__":
            	application_type_inherited_object = QGuiApplication(sys.argv)
            	engine_inherited_object = QQmlApplicationEngine()
            	qt_meta_object_language_file_uniform_resource_identifier = QUrl.fromLocalFile("main.qml")
            	engine_inherited_object.load(qt_meta_object_language_file_uniform_resource_identifier)
            	if not engine_inherited_object.rootObjects():
            		sys.exit(-1)
            	sys.exit(application_type_inherited_object.exec())
            

          The reason I want to do this is because I can't diagnose faults in the QML otherwise; I use VS Code.

          When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

          jsulmJ 1 Reply Last reply
          0
          • RokeJulianLockhartR RokeJulianLockhart

            If you have the same issue, you should comment on the bug report.

            @SGaist, That issue appears to have been closed for a reason I don't understand. However, I've the same problem:

            #!/usr/bin/env -S qml
            import QtQuick 6.9
            import QtQuick.Controls 6.9
            import QtQuick.Layouts 6.9
            ApplicationWindow {
            	visible: true
            	title: qsTr("Application Menu")
            	RowLayout {
            		anchors.centerIn: parent
            		spacing: 10
            		Label {
            			text: "Hello from QML!"
            		}
            		Button {
            			text: "Click Me"
            			onClicked: console.log("Button clicked")
            		}
            	}
            }
            
            

            When I invoke this with qml $HOME/main.qml, I see "Cannot protect module QtQuick.Controls 6 as it was never registered":

            QQmlApplicationEngine failed to load component
            file:///home/RokeJulianLockhart/Documents/main.qml:3:1: plugin cannot be loaded for module "QtQuick.Controls": Cannot protect module QtQuick.Controls 6 as it was never registered
            qml: Did not load any objects, exiting.
            

            If I modify it to be more minimal:

            #!/usr/bin/env -S qml
            import QtQuick 6.9
            ApplicationWindow {
            	visible: true
            	title: qsTr("Application Menu")
            }
            
            

            ...I see:

            main.qml:2:1: module "QtQuick" is not installed

            This shouldn't be possible, because kinfo returns "Qt Version: 6.9.1":

            Operating System: Fedora Linux 42
            KDE Plasma Version: 6.4.4
            KDE Frameworks Version: 6.17.0
            Qt Version: 6.9.1
            Kernel Version: 6.15.9-201.fc42.x86_64 (64-bit)
            Graphics Platform: Wayland
            

            Additionally, if I invoke at least the former version via Python, it works:

            1. #!/usr/bin/env -S python3
              import sys
              from PySide6.QtCore import QUrl
              from PySide6.QtGui import QGuiApplication
              from PySide6.QtQml import QQmlApplicationEngine
              if __name__ == "__main__":
              	application_type_inherited_object = QGuiApplication(sys.argv)
              	engine_inherited_object = QQmlApplicationEngine()
              	qt_meta_object_language_file_uniform_resource_identifier = QUrl.fromLocalFile("main.qml")
              	engine_inherited_object.load(qt_meta_object_language_file_uniform_resource_identifier)
              	if not engine_inherited_object.rootObjects():
              		sys.exit(-1)
              	sys.exit(application_type_inherited_object.exec())
              

            The reason I want to do this is because I can't diagnose faults in the QML otherwise; I use VS Code.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote last edited by
            #5

            @RokeJulianLockhart said in plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...:

            This shouldn't be possible, because kinfo returns "Qt Version: 6.9.1":

            Which does not mean that QtQuick is installed. Make sure it is installed.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            RokeJulianLockhartR 1 Reply Last reply
            0
            • jsulmJ jsulm

              @RokeJulianLockhart said in plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...:

              This shouldn't be possible, because kinfo returns "Qt Version: 6.9.1":

              Which does not mean that QtQuick is installed. Make sure it is installed.

              RokeJulianLockhartR Offline
              RokeJulianLockhartR Offline
              RokeJulianLockhart
              wrote last edited by
              #6

              @jsulm, does what I demonstrated thereafter not confirm that it must be installed? Regardless, the lack of answer to stackoverflow.com/q/59612208 means I've no idea how to ascertain what version is installed (although it should be, and appears to be, 1:1 with the Qt version).

              Note that I solely need to add the version when I invoke it with qml. However, even with that version specified, it works in VSC.

              When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

              1 Reply Last reply
              0
              • A alex_malyu

                It seems bug was either re-introduced or never was fixed:

                https://bugreports.qt.io/browse/QTBUG-81961?jql=text ~ "Cannot protect module QtQuick.Controls 2"

                That's fixed by https://codereview.qt-project.org/c/qt/qtquickcontrols2/+/289223 but is prevented from getting in due to QTBUG-81772, which has a blacklist patch but another part of the test apparently crashes once the tests are blacklisted... ugh.
                I think we can close this in any case.

                I think closing critical bugs without having them pushed to repo is a bad choice.

                In any case I need workaround, It is impossible to develop anything.
                How does it work with other systems?

                I used Qt 5.9.5 on Ubuntu, but need newer version now. Anybody can share which one works on Windows with MinGW?

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

                @alex_malyu said in plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...:

                I think closing critical bugs without having them pushed to repo is a bad choice.

                As discussed at https://bugreports.qt.io/browse/QTBUG-81961, the bug report is invalid.

                The problem is that you specified the wrong version for the import.

                @RokeJulianLockhart said in plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...:

                I see "Cannot protect module QtQuick.Controls 6 as it was never registered"

                Try removing all the version numbers from your import statements. Version numbers are not required (or recommended) in Qt 6.

                This shouldn't be possible, because kinfo returns "Qt Version: 6.9.1":

                What does qml --version show? How about which qml?

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

                RokeJulianLockhartR 1 Reply Last reply
                2
                • JKSHJ JKSH

                  @alex_malyu said in plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...:

                  I think closing critical bugs without having them pushed to repo is a bad choice.

                  As discussed at https://bugreports.qt.io/browse/QTBUG-81961, the bug report is invalid.

                  The problem is that you specified the wrong version for the import.

                  @RokeJulianLockhart said in plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...:

                  I see "Cannot protect module QtQuick.Controls 6 as it was never registered"

                  Try removing all the version numbers from your import statements. Version numbers are not required (or recommended) in Qt 6.

                  This shouldn't be possible, because kinfo returns "Qt Version: 6.9.1":

                  What does qml --version show? How about which qml?

                  RokeJulianLockhartR Offline
                  RokeJulianLockhartR Offline
                  RokeJulianLockhart
                  wrote last edited by RokeJulianLockhart
                  #8

                  What does qml --version show? How about which qml?

                  @JKSH, sensible. Surprisingly, it appears to be from Qt 5:

                  RokeJulianLockhart@Beedell:~$ qml --version
                  Qml Runtime 5.15.17
                  RokeJulianLockhart@Beedell:~$ dnf5 provides $(command -v qml)
                  Updating and loading repositories:
                  Repositories loaded.
                  qt5-qtdeclarative-devel-5.15.17-1.fc42.x86_64 : Development files for qt5-qtdeclarative
                  Repo         : @System
                  Matched From : 
                  Filename     : /usr/bin/qml
                  
                  qt5-qtdeclarative-devel-5.15.17-1.fc42.i686 : Development files for qt5-qtdeclarative
                  Repo         : updates
                  Matched From : 
                  Filename     : /usr/bin/qml
                  
                  qt5-qtdeclarative-devel-5.15.17-1.fc42.x86_64 : Development files for qt5-qtdeclarative
                  Repo         : updates
                  Matched From : 
                  Filename     : /usr/bin/qml
                  
                  qt5-qtdeclarative-devel-5.15.16-2.fc42.i686 : Development files for qt5-qtdeclarative
                  Repo         : fedora
                  Matched From : 
                  Filename     : /usr/bin/qml
                  
                  qt5-qtdeclarative-devel-5.15.16-2.fc42.x86_64 : Development files for qt5-qtdeclarative
                  Repo         : fedora
                  Matched From : 
                  Filename     : /usr/bin/qml
                  
                  RokeJulianLockhart@Beedell:~$ dnf5 info $(rpm -qa qt5-qtdeclarative-devel)
                  Updating and loading repositories:
                  Repositories loaded.
                  Installed packages
                  Name            : qt5-qtdeclarative-devel
                  Epoch           : 0
                  Version         : 5.15.17
                  Release         : 1.fc42
                  Architecture    : x86_64
                  Installed size  : 8.8 MiB
                  Source          : qt5-qtdeclarative-5.15.17-1.fc42.src.rpm
                  From repository : updates
                  Summary         : Development files for qt5-qtdeclarative
                  URL             : http://www.qt.io
                  License         : LGPL-3.0-only OR GPL-3.0-only WITH Qt-GPL-exception-1.0
                  Description     : Development files for qt5-qtdeclarative.
                  Vendor          : Fedora Project
                  

                  Could a Qt 5 library have somehow acquired precedence in $Env:PATH? That might explain all my QML woes.


                  Try removing all the version numbers from your import statements. Version numbers are not required (or recommended) in Qt 6.

                  Glad to hear. Unfortunately, it doesn't improve anything. With:

                  #!/usr/bin/env -S qml
                  import QtQuick // 6.9
                  import QtQuick.Controls // 6.9
                  import QtQuick.Layouts // 6.9
                  ApplicationWindow {
                  	visible: true
                  	title: qsTr("Application Menu")
                  	RowLayout {
                  		anchors.centerIn: parent
                  		spacing: 10
                  		Label {
                  			text: "Hello from QML!"
                  		}
                  		Button {
                  			text: "Click Me"
                  			onClicked: console.log("Button clicked")
                  		}
                  	}
                  }
                  
                  

                  ...I see:

                  main.qml: Library import requires a version

                  Thanks for the assistance, and apologies for the wait.

                  When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

                  JKSHJ 1 Reply Last reply
                  0
                  • RokeJulianLockhartR RokeJulianLockhart

                    What does qml --version show? How about which qml?

                    @JKSH, sensible. Surprisingly, it appears to be from Qt 5:

                    RokeJulianLockhart@Beedell:~$ qml --version
                    Qml Runtime 5.15.17
                    RokeJulianLockhart@Beedell:~$ dnf5 provides $(command -v qml)
                    Updating and loading repositories:
                    Repositories loaded.
                    qt5-qtdeclarative-devel-5.15.17-1.fc42.x86_64 : Development files for qt5-qtdeclarative
                    Repo         : @System
                    Matched From : 
                    Filename     : /usr/bin/qml
                    
                    qt5-qtdeclarative-devel-5.15.17-1.fc42.i686 : Development files for qt5-qtdeclarative
                    Repo         : updates
                    Matched From : 
                    Filename     : /usr/bin/qml
                    
                    qt5-qtdeclarative-devel-5.15.17-1.fc42.x86_64 : Development files for qt5-qtdeclarative
                    Repo         : updates
                    Matched From : 
                    Filename     : /usr/bin/qml
                    
                    qt5-qtdeclarative-devel-5.15.16-2.fc42.i686 : Development files for qt5-qtdeclarative
                    Repo         : fedora
                    Matched From : 
                    Filename     : /usr/bin/qml
                    
                    qt5-qtdeclarative-devel-5.15.16-2.fc42.x86_64 : Development files for qt5-qtdeclarative
                    Repo         : fedora
                    Matched From : 
                    Filename     : /usr/bin/qml
                    
                    RokeJulianLockhart@Beedell:~$ dnf5 info $(rpm -qa qt5-qtdeclarative-devel)
                    Updating and loading repositories:
                    Repositories loaded.
                    Installed packages
                    Name            : qt5-qtdeclarative-devel
                    Epoch           : 0
                    Version         : 5.15.17
                    Release         : 1.fc42
                    Architecture    : x86_64
                    Installed size  : 8.8 MiB
                    Source          : qt5-qtdeclarative-5.15.17-1.fc42.src.rpm
                    From repository : updates
                    Summary         : Development files for qt5-qtdeclarative
                    URL             : http://www.qt.io
                    License         : LGPL-3.0-only OR GPL-3.0-only WITH Qt-GPL-exception-1.0
                    Description     : Development files for qt5-qtdeclarative.
                    Vendor          : Fedora Project
                    

                    Could a Qt 5 library have somehow acquired precedence in $Env:PATH? That might explain all my QML woes.


                    Try removing all the version numbers from your import statements. Version numbers are not required (or recommended) in Qt 6.

                    Glad to hear. Unfortunately, it doesn't improve anything. With:

                    #!/usr/bin/env -S qml
                    import QtQuick // 6.9
                    import QtQuick.Controls // 6.9
                    import QtQuick.Layouts // 6.9
                    ApplicationWindow {
                    	visible: true
                    	title: qsTr("Application Menu")
                    	RowLayout {
                    		anchors.centerIn: parent
                    		spacing: 10
                    		Label {
                    			text: "Hello from QML!"
                    		}
                    		Button {
                    			text: "Click Me"
                    			onClicked: console.log("Button clicked")
                    		}
                    	}
                    }
                    
                    

                    ...I see:

                    main.qml: Library import requires a version

                    Thanks for the assistance, and apologies for the wait.

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

                    @RokeJulianLockhart said in plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...:

                    Could a Qt 5 library have somehow acquired precedence in $Env:PATH? That might explain all my QML woes.

                    That's not it. That qml binary provided by your distro's official repository is based on Qt 5, so it cannot load Qt 6 code.

                    The solution is to avoid /usr/bin/qml which is based on Qt 5. You must either replace that with a Qt 6 version (if your distro supplies it), or use a custom-installed version instead (the Qt Online Installer will let you do ~/Qt/6.9.1/gcc_64/qml main.qml)

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

                    RokeJulianLockhartR 1 Reply Last reply
                    2
                    • JKSHJ JKSH

                      @RokeJulianLockhart said in plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...:

                      Could a Qt 5 library have somehow acquired precedence in $Env:PATH? That might explain all my QML woes.

                      That's not it. That qml binary provided by your distro's official repository is based on Qt 5, so it cannot load Qt 6 code.

                      The solution is to avoid /usr/bin/qml which is based on Qt 5. You must either replace that with a Qt 6 version (if your distro supplies it), or use a custom-installed version instead (the Qt Online Installer will let you do ~/Qt/6.9.1/gcc_64/qml main.qml)

                      RokeJulianLockhartR Offline
                      RokeJulianLockhartR Offline
                      RokeJulianLockhart
                      wrote last edited by
                      #10

                      @JKSH, turns out that I've been through this before, per post/820589. My sincere apologies. How I wish documentation online would cease to cite qml.

                      qml-qt6 ./main.qml works perfectly:

                      When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

                      JKSHJ 1 Reply Last reply
                      0
                      • RokeJulianLockhartR RokeJulianLockhart

                        @JKSH, turns out that I've been through this before, per post/820589. My sincere apologies. How I wish documentation online would cease to cite qml.

                        qml-qt6 ./main.qml works perfectly:

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

                        @RokeJulianLockhart said in plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...:

                        qml-qt6 ./main.qml works perfectly

                        Great! Thanks for sharing.

                        Just remember that you are bound to your distro's version of Qt 6, so the qml-qt6 tool won't be able to process QML code that uses functionality from newer versions.

                        The tool is also intended as a way to quickly preview *.qml files. It won't be able to handle custom types/classes defined from C++ or Python for example (unless you put your class in a C++ plugin that's formally installed)

                        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