应用程序不显示,但有效

Application does not displays, but works

我是 Qt 的新手,我正在尝试按照 here 所述使用 qtquick 编写简单的应用程序。 我的代码:

import QtQuick 2.3

Image {
    id: root
    source: "images/background.png"
}

当我构建它并键入 "Run" 按钮时,它似乎有效,但我根本看不到任何 window!

我做错了什么?

Qt 5.3; qtquick 2.3

系统是Debian 8 Jessie

更新: main.cpp 是原始的:

#include <QApplication>
#include <QQmlApplicationEngine>

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

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    return app.exec();
}

来自文档:

Unlike QQuickView, QQmlApplicationEngine does not automatically create a root window. If you are using visual items from Qt Quick, you will need to place them inside of a Window.

因此您需要在 Image 周围添加 Window