سؤال

I am using Qt Creator 2.4.1 base on Qt 4.7.4(32 bit) on windows. I have to create a table in QML using Table View. When i try import QtQuick.Controls 2.1 i get the error QML MODULE NOT FOUND. Same error on Qt Creator 2.6.2 based on Qt 5.0.1. Any help appreciated.

هل كانت مفيدة؟

المحلول 2

The module QtQuick.Controls has been added on Qt 5.1 and is currently at the 1.0 version. It also requires you having QtQuick version 2.0, introduced with Qt 5 So if you want to use TableView you would have to update your current Qt version to at least 5.1 and then use these import statement:

import QtQuick 2.0
import QtQuick.Controls 1.0

Also, as indicated by Armaghast in the comment, if you are moving to the latest Qt version (currently Qt 5.2.1) you should use

import QtQuick 2.2
import QtQuick.Controls 1.1

نصائح أخرى

In my case running qmake fixed issue.

Update 2020 (new way):
In some cases it not helped. Instead this solution helped greatly.
In the QtCreator, open settings/preferences and go to QtQuick > QtQuick Designer and select Use QML emulation layer... option in Qml Emulation Layer section and get your most newer version of Qt to it as follow:
settings of qml emulatiln

In October 2016, Qt Qtuick Controls 2.1 were released as part of Qt 5.8

If anybody (like me) stumbles upon this error when using someone else code, you need to install Qt 5.8 or newer. Lower versions will fail to run the QML GUI.

More info at: http://blog.qt.io/blog/2016/10/06/qt-quick-controls-2-1-and-beyond/

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top