The correct way to open a new window



  • Dear All,

    i created a simple QT application.

    Please note this is my first time with QT so sorry for all my misunderstandings.

    The mail file i main.qml file with a button.

    When i clicks the button, i opened a new window/file MapModule.qml file in this way:

    Button {
               id: btnLogin
               text: "Login"
               onClicked: {
                   var component = Qt.createComponent("MapModule.qml");
                   var  win = component.createObject(root);
                   win.show();
               }
           }
    

    If i run the application with MAC pc or iOS Device works fine!

    If i run with Android Device the application shows ever the main.qml screen.
    I tried to run some code like

    hide() 
    

    but the system doesn't' work fine.

    The one way to works is to set the width and height to 0 of the main qml before shows the second qml. But if i rotates the device how to magic the main page return with the default height and width.

    I think this is not the correct way to open a new window.

    Could you please show me a simple example for the correct way to open a new qml file of if i need to know something?

    Really thanks for the availability of this forum.

    Tony



  • Dear All,

    seems that the problem is only with ANDROID and QML file.
    How is possible this?

    I tried to open 2 .cpp window and works fine in all devices (ios and android).

    Now i tried to open the qml from .cpp file and works fine only on Desktop and ios. On android not appear nothing.

    void MainWindow::on_pushButton_clicked()
    {
    
          QQuickView *view = new QQuickView;
          view->setSource(QUrl("qrc:/page2.qml"));
    
          view->show();
    }
    

    There are other way to open QML file?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.