Advise on multiple top level QQuickView's
-
Hi,
I have an upcoming project that I would like Qt Quick 2 for, this particular project requires two top level scenes, full screen, on 2 separate monitors but they do have a requirement to share qml items. What is the best way to achieve this? Would multiple QQuickView's work sharing the same QQmlEngine or is there a better approach?
Thanks
-
Qt Quick 2 has built-in support for this. If you write the entire UI in Qt Quick, you can instead declare multiple instances of Window or ApplicationWindow in QML itself and use the non visual QQmlApplicationEngine to launch your app and implicitly create those windows using the same engine.
-
Right, so the top level QML file loaded by QQmlApplicationEngine would simply have 2 top level Window items inside it? I gather these can be configured to setScreen and fullscreen also then?
-
Yes. If you check the Window api here:
http://doc-snapshot.qt-project.org/qt5-stable/qtquick/qml-qtquick-window2-window.html -
Thought you could only have one top level qml root node? If this is the case how can I achieve 2 top level windows in qml. Seems both windows would always need a top level parent?
Thanks
-
Unlike QQuickView, your root node can be a simple QtObject if you are using QmlApplicationEngine. So in effect there is no such constraint.
@
QtObject {
property var test: Window {
width: 100
height: 100
visible: true
}
property var test2: Window {
width: 100
height: 100
visible: true
}
}
@Note that windows are not visible by default so you have to explicitly make them visible when doing this. (Root windows are implicitly set visible otherwise)
-
excellent, thanks for your help