0
votes

My Qt application is failing to start with the following error: module "QtQuick.Controls" version 2.12 is not installed

My platform is Ubuntu 20.04.2 LTS. This is a well-known error on StackOverflow. Unfortunately, no answers have worked for me this far. I have exhausted all suggested remedies without any improvement. These are enumerated below:

  1. Checking compatibility of Qt with QuickControls: I am using Qt 5.12.8 in QtCreator, and QtCreator 4.11.0. I installed Qt using sudo apt install qt5 default and sudo apt-get install qtcreator. According to the documentation (see here, Qt 5.12 is directly compatible with QtQuick 2.12:
  2. Checking if I specified QtQuick as a dependency: In my .pro file, I have added QT += quick qml quickcontrols2
  3. Checking if I have the right libraries: I have qtquickcontrols2-5-dev, qt5declarative5-dev, and qml-module-qtquick-controls. Furthermore, apt-cache search qtquick shows me that all the qtquick modules are there
  4. Re-installing qtcreator: Some questions suggest re-installing QtCreator. I have tried this, but it had no effect
  5. QML Emulation layer: I have configured my project to "Use QML emulation layer that is built with the selected Qt". However, this also had no effect

Having performed every one of these steps, and exhausted all StackOverflow questions and Github threads related to the topic, I still cannot find what is causing this issue.


I have additionally included some related questions that I've tried. Question 4 is perhaps the closest to mine, but was solved via the Yocto build system that I am not using:

  1. import QtQuick.Controls 2.1 QML MODULE NOT FOUND
  2. Error module "QtQuick" version 2.12 is not installed
  3. Ubuntu QT install qt quick controls 2.1
  4. Qt - Module "QtQuick.Controls" is not installed

I would be extremely appreciative of any advice on further resolving this matter.

1
How are you running the application? From within QtCreator or external (i.e. from command line).Amfasis
@Amfasis From within QtCreator. Although I've also just executed the binary myself from the terminal. Neither workMicrified
do you find libQt5QuickControls2.so.5 in the output of ldconfig (or sudo ldconfig)?Amfasis
@Amfasis In /usr/lib/x86_64-linux-gnu, I have libQt5QuickControls2.so.5, libQt5QuickControls2.so.5.12, and libQt5QuickControls2.so.5.12.8.Micrified
but if those are not found by ldconfig you need to update your ld-conf. You can probably run the application with LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu app?Amfasis

1 Answers

1
votes

You are missing the qml module for controls 2 because you have installed qml-module-qtquick-controls instead of qml-module-qtquick-controls2.

The QML engine will look for a module inside the path from QML2_IMPORT_PATH, by following the namespaces, so in this case QML2_IMPORT_PATH/QtQuick/Controls and QML2_IMPORT_PATH/QtQuick/Controls.2 (see version semantics documentation ). If in these folders it finds a qmldir file, it will parse it and look for any component that has at least 2 as major and something lower or equal to 12 as minor (allthough this particular qmldir doesn't state any components... it probably also reads the libqtquickcontrols2plugin.so or plugin.qmltypes)