如何运行导入QtQuick2.0和QtQuick.Controls 1.1的应用程序

如何运行导入QtQuick2.0和QtQuick.Controls 1.1的应用程序,qt,qml,qt5,Qt,Qml,Qt5,我第一次创建了qtquick应用程序。我使用QtCreator 3.0、Qt5.2.0和MSVC2012。 当我编写下面的代码时,我收到了错误消息。我明白上面说的。但如果可能的话,我想使用QtQuick 2.0而不是1.0 有人知道如何修复错误吗? 任何帮助都将不胜感激。提前谢谢 示例代码 QQuickView only supports loading of root objects that derive from QQuickItem. If your example is using

我第一次创建了qtquick应用程序。我使用QtCreator 3.0、Qt5.2.0和MSVC2012。 当我编写下面的代码时,我收到了错误消息。我明白上面说的。但如果可能的话,我想使用QtQuick 2.0而不是1.0

有人知道如何修复错误吗? 任何帮助都将不胜感激。提前谢谢

示例代码

QQuickView only supports loading of root objects that derive from QQuickItem. 

If your example is using QML 2, (such as qmlscene) and the .qml file you 
loaded has 'import QtQuick 1.0' or 'import Qt 4.7', this error will occur. 

To load files with 'import QtQuick 1.0' or 'import Qt 4.7', use the 
QDeclarativeView class in the Qt Quick 1 module. 
[main.qml]

[main.cpp]


您需要使用选项“Qt Quick Control 1.0”而不是“Qt Quick 2.0”生成Qt Quick应用程序项目。它将生成
QtQuick2ControlsApplicationViewer
类,该类不使用
QQuickView
,只使用
qqqmlcomponent

谢谢你的建议。当我使用选项“Qt Quick Control 1.0”创建项目时,它会工作。我误解了组件集。
#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile(QStringLiteral("qml/QtQuickAppTest/main.qml"));
    viewer.showExpanded();

    return app.exec();
}
QQuickView only supports loading of root objects that derive from QQuickItem. 

If your example is using QML 2, (such as qmlscene) and the .qml file you 
loaded has 'import QtQuick 1.0' or 'import Qt 4.7', this error will occur. 

To load files with 'import QtQuick 1.0' or 'import Qt 4.7', use the 
QDeclarativeView class in the Qt Quick 1 module.