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 display QML screen from the JavaScript code.

How to display QML screen from the JavaScript code.

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 3.5k 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.
  • A Offline
    A Offline
    at_pradeep
    wrote on 3 Oct 2011, 06:12 last edited by
    #1

    How to display QML screen from the JavaScript code, on some external events i need to display new QML screen from the javascript code.
    To load new QML screen we need to use Loader and we need to change the source of the loader to display the new screen.
    I want to display new QML screen on top of the existing QML screen from the javascript.

    Thanks.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on 3 Oct 2011, 07:24 last edited by
      #2

      Hello,

      "Dynamic Object Management in QML article":http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.html might help you.

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0
      • A Offline
        A Offline
        at_pradeep
        wrote on 3 Oct 2011, 07:36 last edited by
        #3

        Hi,

        Thanks for the reply,
        Does "component.createObject(appWindow, {"x": 100, "y": 100});" creates and displays QML object on the screen? Suppose I have text box in the QML file which i am going to create using "createObject", so how should I set the text of that text box. is it something like this "newQmlObject.testTextBox.text = 'this is test';" or is there any other way?

        Thanks.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          task_struct
          wrote on 3 Oct 2011, 08:04 last edited by
          #4

          Yes, component.createObject() will create and display object on position 100, 100. Also it returns an object instance of this component, so you are able to modify it`s properties.

          For eample:

          @
          var cmp = component.createObject(appWindow, {“x”: 100, “y”: 100});
          cmp.width = 100;
          @

          Also you can use "createQmlObject":http://doc.qt.nokia.com/4.7-snapshot/qml-qt.html#createQmlObject-method . You should decide what is best in your case.

          "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

          • Linu...
          1 Reply Last reply
          0
          • A Offline
            A Offline
            at_pradeep
            wrote on 3 Oct 2011, 09:46 last edited by
            #5

            Ok go it, but can we access components/widgets (not properties) in side the newly created qml object? Also how can remove a screen from the display.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              task_struct
              wrote on 3 Oct 2011, 10:43 last edited by
              #6

              To remove object you can call your_object.destroy(ms_to_wait_before_removing_object) (see "Deleting objects dynamically":http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.html#deleting-objects-dynamically )

              You can access items inside created component throught "children property":http://doc.qt.nokia.com/4.7-snapshot/qml-item.html#children-prop , but I think it will be easier to use "property aliases":http://doc.qt.nokia.com/latest/qml-extending-types.html#property-aliases for children properties you need.

              "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

              • Linu...
              1 Reply Last reply
              0

              6/6

              3 Oct 2011, 10:43

              • Login

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