Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How run two ApplicationWindow in qml with Studio3D présentation?
Qt 6.11 is out! See what's new in the release blog

How run two ApplicationWindow in qml with Studio3D présentation?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 1 Posters 785 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    filipdns
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • F Offline
      F Offline
      filipdns
      wrote on last edited by
      #2

      Update, using import QtQuick.Window 2.11 decrease significantly the loading time but may be better solution exist

      1 Reply Last reply
      0
      • F Offline
        F Offline
        filipdns
        wrote on last edited by
        #3

        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.0

        Window {
        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: parent

            Presentation {
                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.0

        Window {
            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"
                }
        
            }
        
        }
        
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved