Unsolved How run two ApplicationWindow in qml with Studio3D présentation?
-
Hello, working on car cluster project, I need to have 2 applicationWindows, one on each screens.
I try with 2 loaders and 1 qml for each screen but only the last loader is running (like if I call a second loader, it's just replacing the source of the first loader... Strange...)
Then I try with 2 windows on same main.qml:
I did it working with code below but it's taking longtime to start both presentation, do you have better solution to do that?
import QtQuick 2.3 import QtStudio3D 2.0 import QtQuick.Window 2.3 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import Qt.labs.platform 1.0 ApplicationWindow{ id:appwindow visible: true // this is mandatory Window { id: window objectName: "wnd1" visibility: Window.FullScreen screen: Qt.application.screens[0] || null Studio3D { id: s3d focus: true //height:300 //width:400 anchors.fill: parent Presentation { id: s3dpres source: "file:///f:/corvette_cluster_2018/corvette_cluster_2018.uia" } } } Window { id: window2 objectName: "wnd2" visibility: Window.FullScreen screen: Qt.application.screens[1] || null Studio3D { id: s3d2 focus: true //height:300 //width:400 anchors.fill: parent Presentation { id: s3dpres2 source: "file:///d:/Qt/Tools/Qt3DStudio/examples/studio3d/SampleProject/SampleProject.uia" } onPresentationReady:{} } } }
Thank you very much for your help
-
Update, using import QtQuick.Window 2.11 decrease significantly the loading time but may be better solution exist
-
I found simplest way to do
main.cpp
#include <QtWidgets/QApplication> // for MessageDialog #include <QtQuick/QQuickView> #include <q3dsruntimeglobal.h> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { qputenv("QT_OPENGL", "desktop"); // Change QT_OPENGL environement variable from originaly "angle" to "desktop" QGuiApplication app(argc, argv); // Use the ideal format (i.e. OpenGL version and profile) recommended by // the Qt 3D Studio runtime. Without this the format set on the QQuickView // would be used instead. QSurfaceFormat::setDefaultFormat(Q3DS::surfaceFormat()); QQmlApplicationEngine engine1(QUrl(QStringLiteral("qrc:/Screen1.qml"))); QQmlApplicationEngine engine2(QUrl(QStringLiteral("qrc:/Screen2.qml"))); return app.exec(); } Screen1.qml
import QtQuick 2.3
import QtStudio3D 2.0
import QtQuick.Window 2.11
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import Qt.labs.platform 1.0Window {
id: window2
objectName: "wnd2"
visible: true // this is mandatory
visibility: Window.FullScreen
screen: Qt.application.screens[1] || null
Studio3D {
id: s3d2
focus: true
//height:300
//width:400
anchors.fill: parentPresentation { id: s3dpres2 source: "file:///d:/Qt/Tools/Qt3DStudio/examples/studio3d/SampleProject/SampleProject.uia" } onPresentationReady:{} }
}
Screen2.qml
import QtQuick 2.3
import QtStudio3D 2.0
import QtQuick.Window 2.11
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import Qt.labs.platform 1.0Window { id: window objectName: "wnd1" //visible: true // this is mandatory visibility: Window.FullScreen screen: Qt.application.screens[0] || null Studio3D { id: s3d focus: true //height:300 //width:400 anchors.fill: parent Presentation { id: s3dpres source: "file:///f:/corvette_cluster_2018/corvette_cluster_2018.uia" } } }