0
votes

In QML Doc, there are the following:

Import Statement:

import QtQuick.Controls 2.2

Since: Qt 5.7

"ComboBox can be made editable." ...

I have latest Qt OpenSource 5.9 installed. But I can not import the QtQuick.Controls 2.2, even with the simplest qt quick project created by the project wizard. The following error is print:

qrc:/main.qml:2 module "QtQuick.Controls" version 2.2 is not installed

My code:

import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3

ApplicationWindow {
...

main.cpp

#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    engine.load(QUrl(QLatin1String("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}

All codes are generated by Qt Creator 4.3

I work on windows 7.

1
Can you check if you have installed QtQuick.Controls 2 or not. You can check this by traversing through the folder where Qt is installed. For example, for me Qt5.9.0\5.9\mingw53_32\qml\QtQuick\Controls.2 is the folder where QtQuick.Controls 2.2 components like ComboBox are presentPraveen Kumar
Yes, I found the ComboBox under C:\Qt\Qt5.9.0\5.9\msvc2015_64\qml\QtQuick\Controls.2Jas6033
I just found I used the 5.8 kit, sorry and thanks.Jas6033

1 Answers

0
votes

If you have QtQuick 2.7 installed, you need to import QtQuick.Controls 2.0. The import statement in the documentation is sometimes set to the newest version.
This might happen, e.g. when a new property is introduced in a newer version (see acceptableInput)

The ComboBox per se is available since Qt5.7 and the corresponding QtQuick.Controls 2.0, but some properties have been added in QtQuick.Controls 2.2 which comes with Qt5.9.