[ACCEPTED]-What's the difference between QQuickView and QQuickWindow?-qt-quick

Accepted answer
Score: 22

From the Qt documentation:

The QQuickView 15 class provides a window for displaying a 14 Qt Quick user interface.

QQuickView is 13 a convenience subclass of QQuickWindow which 12 will automatically load and display a 11 QML scene when given the URL of the main 10 source file.

So QQuickView is a subclass 9 of QQuickWindow which manages displaying 8 a scene from a QML file and could be used 7 easily like:

QQuickView *view = new QQuickView;

For displaying a graphical QML 6 scene in a window you can also use the QQuickWindow 5 class.

Also from the Qt documentation:

A QQuickWindow 4 always has a single invisible root item. To 3 add items to this window, reparent the 2 items to the root item or to an existing item 1 in the scene.

So it can be used like:

QQmlApplicationEngine engine;

QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);


More Related questions