plugin cannot be loaded for module "QtQuick.Layouts": Cannot protect module QtQuick.Layouts 2 as it was never registered QML debugging is enabled...
-
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.15In 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?
-
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?
-
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.
-
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.
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 moduleQtQuick.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 installedThis 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:
-
#!/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.
-
-
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 moduleQtQuick.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 installedThis 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:
-
#!/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.
@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.
-
-
@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.
@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. -
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?
@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 aboutwhich qml
? -
@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 aboutwhich qml
?What does
qml --version
show? How aboutwhich 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 versionThanks for the assistance, and apologies for the wait.
-
What does
qml --version
show? How aboutwhich 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 versionThanks for the assistance, and apologies for the wait.
@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
) -
@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
)@JKSH, turns out that I've been through this before, per
post/820589
. My sincere apologies. How I wish documentation online would cease to citeqml
.qml-qt6 ./main.qml
works perfectly: -
@JKSH, turns out that I've been through this before, per
post/820589
. My sincere apologies. How I wish documentation online would cease to citeqml
.qml-qt6 ./main.qml
works perfectly:@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 perfectlyGreat! 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)