Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How to interact in between two QML screens?

    QML and Qt Quick
    3
    5
    4524
    Loading More Posts
    • 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.
    • A
      at_pradeep last edited by

      How to interact in between two QML screens?
      I am creating new QML component/screen by using "createComponent" and "createObject".

      @var component = Qt.createComponent("testQml.qml");
      var sprite = component.createObject(parentWindow, {"x":0, "y":0});
      if(sprite == null)
      {
      console.log("Error creating component\n");
      return;
      }
      console.log("Screen Created\n");
      // Send some data to the newly created screen
      @

      I have some data that I need to pass it to the newly created screen before it displays the UI components.
      I need two way communication in between child and the parent screen.
      I also need to call some function of the parent QML screen from child screen.

      how it is done in the QML?

      Thanks.

      1 Reply Last reply Reply Quote 0
      • D
        digitalsurgeon last edited by

        May be you can use properties and signals to pass data around ?

        1 Reply Last reply Reply Quote 0
        • A
          at_pradeep last edited by

          Can you please provide one example for this (using two qml/js files).
          One way I found is common javascript file in between two QML files and from QML file accessing global key value pares (global array) to send and receive parameters across two QML files.

          1 Reply Last reply Reply Quote 0
          • R
            raja26 last edited by

            Here.. Using a common Javascript file to share data.

            Global.js
            @
            .pragma library
            var sharedVariable = null;
            @

            Your Screen1.qml
            @
            import "Global.js" as GlobalJS

            Rectangle {
            MouseArea {
            anchors.fill:parent
            onClicked: GlobalJS.sharedVariable = "This is shared data";
            }
            }
            @

            Your Screen2.qml
            @
            import "Global.js" as GlobalJS

            Rectangle {
            Text {

            text: GlobalJS.sharedVariable
            }
            }
            @

            1 Reply Last reply Reply Quote 0
            • A
              at_pradeep last edited by

              Thanks for the reply

              1 Reply Last reply Reply Quote 0
              • First post
                Last post