Search code examples
qtqt5qt-quick

Application does not displays, but works


I'm new in Qt and I'm trying to write simple app with qtquick as described here. My code :

import QtQuick 2.3

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

When I build it and type "Run" button, it seems works, but I can't see any window at all!

What am I doing wrong?

Qt 5.3; qtquick 2.3

System is Debian 8 Jessie

UPD: main.cpp is primitive:

#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();
}

Solution

  • From the documentation:

    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.

    So you need to add Window around your Image.