Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to create and show new QML,in Android
Forum Updated to NodeBB v4.3 + New Features

How to create and show new QML,in Android

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
12 Posts 3 Posters 3.9k Views 2 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.
  • T Offline
    T Offline
    THEFree
    wrote on last edited by A Former User
    #1
    import QtQuick 2.5
    import QtQuick.Controls 2.0
    import QtQuick.Window 2.0
    
    Rectangle {
        id:circleFriends
    
    
        Rectangle{
            height: Screen.height
            width: Screen.width
    //        x:circleFriends.width
    
    //        PropertyAnimation on x{
    //            to:0; duration:1000;loops:Animation.Infinite
    //        }
        }
    
    }
    
    

    i want to open new window

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @THEFree Please elaborate your question.

      157

      T 1 Reply Last reply
      0
      • p3c0P p3c0

        @THEFree Please elaborate your question.

        T Offline
        T Offline
        THEFree
        wrote on last edited by
        #3

        @p3c0 main.qml 's button Click on a button to open a new window

        open this “QML”

        import QtQuick 2.5
        import QtQuick.Controls 2.0
        import QtQuick.Window 2.0
        
        Rectangle {
            id:circleFriends
        
        
            Rectangle{
                height: Screen.height
                width: Screen.width
        //        x:circleFriends.width
        
        //        PropertyAnimation on x{
        //            to:0; duration:1000;loops:Animation.Infinite
        //        }
            }
        
        }
        
        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @THEFree
          Following can be done for dynamic object creation and loading:

          • Qt.createComponent() or Qt.createQmlObject()
            Check this document for more info.
          • Loader

          If you want separate windows you will need to use Window as root object.

          157

          T 1 Reply Last reply
          0
          • S Offline
            S Offline
            stcorp
            wrote on last edited by
            #5

            Maybe you could try using a stackview? http://doc.qt.io/qt-5/qml-qtquick-controls2-stackview.html

            main.qml

            import QtQuick 2.7
            import QtQuick.Controls 2.0
            
            ApplicationWindow {
                visible: true
                width: 500
                height: 500
            
                StackView
                {
                    id: stackview
                    initialItem:
                        Pane
                        {
                            Button
                            {
                                text: "Open window"
                                onClicked: stackview.push("qrc:/window.qml")
                            }
                        }
                }
            }
            

            window.qml

            import QtQuick 2.0
            import QtQuick.Controls 2.0
            
            Pane {
                Column
                {
                    Button
                    {
                        text: "Close"
                        onClicked: stackview.pop()
                    }
                    Label
                    {
                        text: "This is an opened window"
                    }
                }
            }
            
            1 Reply Last reply
            0
            • p3c0P p3c0

              @THEFree
              Following can be done for dynamic object creation and loading:

              • Qt.createComponent() or Qt.createQmlObject()
                Check this document for more info.
              • Loader

              If you want separate windows you will need to use Window as root object.

              T Offline
              T Offline
              THEFree
              wrote on last edited by
              #6

              @p3c0

              main.qml open other.qml, I think it should be open。

              Because main.qml can't click,But other.qml can't see, If I click back, mail.qml can click

              1 Reply Last reply
              0
              • p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #7

                @THEFree

                Because main.qml can't click

                Why it doesn't ? Can you post the code ?

                157

                T 1 Reply Last reply
                0
                • p3c0P p3c0

                  @THEFree

                  Because main.qml can't click

                  Why it doesn't ? Can you post the code ?

                  T Offline
                  T Offline
                  THEFree
                  wrote on last edited by
                  #8

                  @p3c0

                  mail.qml

                  var component;
                  var sprite;
                  
                  function createSpriteObjects() {
                      component = Qt.createComponent("qml/CircleFriends.qml");
                      if (component.status == Component.Ready)
                          finishCreation();
                      else
                          component.statusChanged.connect(finishCreation);
                  }
                  
                  function finishCreation() {
                      if (component.status == Component.Ready) {
                          sprite = component.createObject(mainWindow, {"x": 0, "y": 0});
                          if (sprite == null) {
                              // Error Handling
                              console.log("Error creating object");
                          }
                      } else if (component.status == Component.Error) {
                          // Error Handling
                          console.log("Error loading component:", component.errorString());
                      }
                  }
                  
                  

                  other.qml

                  import QtQuick 2.5
                  import QtQuick.Controls 2.0
                  import QtQuick.Window 2.0
                  
                  ApplicationWindow {
                      id:circleFriends
                      height: Screen.height
                      width: Screen.width
                      visible: true
                  
                      Rectangle{
                            anchors.fill: parent
                  //        x:circleFriends.width
                  
                  //        PropertyAnimation on x{
                  //            to:0; duration:1000;loops:Animation.Infinite
                  //        }
                      }
                  
                  }
                  
                  

                  PC is ok,android is nothing

                  1 Reply Last reply
                  0
                  • p3c0P Offline
                    p3c0P Offline
                    p3c0
                    Moderators
                    wrote on last edited by
                    #9

                    @THEFree Sorry but I don't see any connection between the 2 QML's. I dont see how you load other.qml in main.qml and also anything related to click.

                    157

                    T 1 Reply Last reply
                    0
                    • p3c0P p3c0

                      @THEFree Sorry but I don't see any connection between the 2 QML's. I dont see how you load other.qml in main.qml and also anything related to click.

                      T Offline
                      T Offline
                      THEFree
                      wrote on last edited by
                      #10

                      @p3c0 createSpriteObjects()

                      The pop-up window is transparent in android

                      1 Reply Last reply
                      0
                      • p3c0P Offline
                        p3c0P Offline
                        p3c0
                        Moderators
                        wrote on last edited by
                        #11

                        @THEFree I think the problem is with multiple windows. I guess android doesn't support it.

                        157

                        T 1 Reply Last reply
                        0
                        • p3c0P p3c0

                          @THEFree I think the problem is with multiple windows. I guess android doesn't support it.

                          T Offline
                          T Offline
                          THEFree
                          wrote on last edited by
                          #12

                          @p3c0 use StackView is ok,Thank God, thank you

                          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