How to build using updated QML plugins after installing newer version of Qt
-
Hi all,
I am new to Qt Quick and am trying to get some demo applications up and running. I am running in Ubuntu 18.04 an initially installed Qt through the command line just using apt-get. This installed Qt 5.9.5 and corresponding libraries and plugins. Which was a fine place to start.
But as I got going I realized that 5.9.5 only supports up to QtQuick.Controls 2.2 and MenuBar, which I want to implement, is implemented in Controls 2.5 which is in Qt 5.10.0 (https://doc.qt.io/qt-5/qml-qtquick-controls2-menubar.html).
So I downloaded the Qt 5.10.1 installer and installed it. I relaunched Qt Creator and updated my default Kit to 5.10.1. That all appears to be working fine. I can look at the Makefile generated by qmake and see all of the references to the 5.10.1 toolchain... but I cannot seem to figure out how to get the new Qt Quick modules in. If I am editing my QML file in Qt Creator and I try to import QtQuick.Controls it still only shows version 2.0, 2.1, or 2.2 as available.
If I just ignore Qt Creator and update the version to 2.5, qmake, rebuild, and run. I get the following error:
QQmlApplicationEngine failed to load component qrc:/qml/main.qml:4 module "QtQuick.Controls" version 2.5 is not installed ASSERT: "!isEmpty()" in file /opt/qt/5.10.1/5.10.1/gcc_64/include/QtCore/qlist.h, line 345 Aborted (core dumped)
I have tried adding the import paths to my project file:
# Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = /usr/lib/x86_64-linux-gnu/gstreamer-1.0/ QML_IMPORT_PATH += /opt/qt/5.10.1/5.10.1/gcc_64/qml/ QML2_IMPORT_PATH += /opt/qt/5.10.1/5.10.1/gcc_64/qml/ # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = /opt/qt/5.10.1/5.10.1/gcc_64/qml/
But nothing I do seems to have any affect. What am I missing? It seems like it shouldn't be this hard to update to newer versions of plugins? I see the QML files and shared libraries sitting in /opt/qt/5.10.1/5.10.1/gcc_64/qml/QtQuick/Controls.2. How do I get my application to link against them?
Thanks
-
Try uninstalling system Qt perhaps? Or check your
$PATH
andenv
maybe the OS plugins are inserted with higher priority for some reason? -
Okay. I have things partially figured it out. I found this documentation (https://doc.qt.io/qt-5/qtquick-deployment.html) which states that:
When running applications on the target platform, the application needs to access the location of the QML libraries. When using qmake, the QT_INSTALL_QML environment points to the location of the libraries. The Qt Installers install the QML libraries in <version>/<compiler>/qml directory.
Makes sense. So I set
QT_INSTALL_QML=/opt/qt/5.10.1/5.10.1/gcc_64/qml/
and, voila!, no run-time error that QtQuick.Controls isn't installed. (I did actually need to correct the imported version from 2.5 to 2.3 because if you look at the version table (https://doc.qt.io/qt-5/qtquickcontrols-index.html) you will see that is what Qt 5.10 ships with.)So I'm almost there. I have things working at run-time now, but Qt Creator/Designer is still showing me an error when I import version 2.3. Things still qmake, make, and run... but it appears the Qt tools are out of sync with reality. How/Where is Qt Creator looking for the available QML installation?
-
In Qt creator installation dir there is
bin
directory, and Qt Creator launch script - see if you can modify something there.Or perhaps a simple addition of
QT_INSTALL_QML
to your~/.profile
file will do the trick (don't forget to log out and back in after you modify that file).