QT can't load qml controls
-
I tried to run an application, but it seems that .qml can't be loaded correctly, the error message is:
qrc:/main.qml:2:1: module "QtQuick.Controls" version 1.1 is not installed
In main.qml, there is a code line: import QtQuick.Controls 1.1, and QT can't find the control with version 1.1
But this application can run well previously.
I searched for solutions on the web, but none of them could solve this issue.
What should I do to resolve this problem? -
@FatGarfield said in QT can't load qml controls:
but new error
"QQmlApplicationEngine failed to load component
qrc:/main.qml:64:5: TabView is not a type"
appears.This is because while you have changed the import, the code is still referencing types that were available in Qt Quick Controls 1.
Qt Quick Controls 1 was deprecated in Qt 5 and its functionality was largely replaced with what was initially called Qt Quick Controls 2. Although this had similar types and functionality the API was not generally compatible with Qt Quick Controls 1.
In Qt 6, Qt Quick Controls 1 has been completely removed and what used to be called Qt Quick Controls 2 is just Qt Quick Controls. So when you modified the import to reference Qt Quick Controls, the import looks correct, but the code is still written as if it is still using Qt Quick Controls 1 and will fail.
I would recommend that you go back to Qt 5, where Qt Quick Controls 1 is still available alongside Qt Quick Controls 2, and port your code there before attempting to port to Qt 6.
-
@FatGarfield said in QT can't load qml controls:
But this application can run well previously.
So, what changed since then?
What Qt version do you use and how did you install it?
See https://doc.qt.io/qt-6/qtquickcontrols-index.html -
@FatGarfield
For Qt5 (version 5.15 )
import QtQuick.Controls 2.15
For Qt6(no version number is needed)
import QtQuick.Controls -
@JoeCFD Thanks for your relply, I use QT 6.2.4, and according to your suggestion. I changed
import QtQuick 2.2
import QtQuick.Controls 1.1to
import QtQuick
import QtQuick.Controlserror message "qrc:/main.qml:2:1: module "QtQuick.Controls" version 1.1 is not installed
" no longer exists.but new error
"QQmlApplicationEngine failed to load component
qrc:/main.qml:64:5: TabView is not a type"
appears. -
@FatGarfield said in QT can't load qml controls:
@jsulm Thanks for your relply, I use QT 6.2.4. Nothing changed, I ran this program several years ago, and it did not work now.
Qt Quick Controls 1 has never been available in Qt 6. When you ran it several years ago it cannot have been building and running with any Qt 6 version. It would always have given an error like this with Qt 6.
-
@FatGarfield said in QT can't load qml controls:
but new error
"QQmlApplicationEngine failed to load component
qrc:/main.qml:64:5: TabView is not a type"
appears.This is because while you have changed the import, the code is still referencing types that were available in Qt Quick Controls 1.
Qt Quick Controls 1 was deprecated in Qt 5 and its functionality was largely replaced with what was initially called Qt Quick Controls 2. Although this had similar types and functionality the API was not generally compatible with Qt Quick Controls 1.
In Qt 6, Qt Quick Controls 1 has been completely removed and what used to be called Qt Quick Controls 2 is just Qt Quick Controls. So when you modified the import to reference Qt Quick Controls, the import looks correct, but the code is still written as if it is still using Qt Quick Controls 1 and will fail.
I would recommend that you go back to Qt 5, where Qt Quick Controls 1 is still available alongside Qt Quick Controls 2, and port your code there before attempting to port to Qt 6.
-