Jas6033
Jas6033

Reputation: 105

When using Editable ComboBox,I can NOT import QtQuick.Controls 2.2

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.

Upvotes: 0

Views: 678

Answers (1)

derM
derM

Reputation: 13691

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.

Upvotes: 0

Related Questions