Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. The correct way to open a new window
Qt 6.11 is out! See what's new in the release blog

The correct way to open a new window

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
2 Posts 1 Posters 672 Views
  • 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.
  • T Offline
    T Offline
    tonyhhkx
    wrote on last edited by
    #1

    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

    T 1 Reply Last reply
    0
    • T tonyhhkx

      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

      T Offline
      T Offline
      tonyhhkx
      wrote on last edited by
      #2

      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?

      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