Import failure(bug?)
-
Hello,
i've created a brand new qtquick2applicationviewer application, but i also tested it with a QQuickView. I've got a QML-file loaded including this code:
@import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1ApplicationWindow {
width: 200
height: 200
title: qsTr("Sample");
color: "black"
}@
This message displays in my console:bq. 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.It does not occur when i am using a Rectangle as my top-level component.
@import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1Rectangle {
width: 200
height: 200
color: "black"
}@All the other files in my project are unchanged.
Am i using ApplicationWindow wrong or is this maybe a bug?
-
Try creating a new project with qtquick controls. Check if this Hello World doesn't run, must be your installation problem.
-
Thanks for your reply, i've tried it with a generated QtQuickControls 1.0 project and it worked fine.
-
My QtQuick initializing code:
@MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QQuickView *view = new QQuickView(QUrl("qrc:/qml/main.qml"));
QWidget::createWindowContainer(view, this);
}@I would guess that the problem is this line:
@QWidget::createWindowContainer(view, this);@Currently i am using a qtquick2controlsapplicationviewer and it works fine so far.
Provisionally solved