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 position dynamic created qml obj?
Forum Updated to NodeBB v4.3 + New Features

How to position dynamic created qml obj?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 4 Posters 1.1k 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.
  • M Offline
    M Offline
    Mr Pang
    wrote on 18 Oct 2016, 11:46 last edited by
    #1

    I have such code

    var compoment = Qt.createComponent("qrc:/ui/About.qml");
    var obj = compoment.createObject(window,{"width": list.width, "height": list.height});
    
                            
    

    How to set anchors value for obj? Such anchors.fill: parent

    R 1 Reply Last reply 18 Oct 2016, 11:50
    0
    • M Mr Pang
      18 Oct 2016, 11:46

      I have such code

      var compoment = Qt.createComponent("qrc:/ui/About.qml");
      var obj = compoment.createObject(window,{"width": list.width, "height": list.height});
      
                              
      

      How to set anchors value for obj? Such anchors.fill: parent

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 18 Oct 2016, 11:50 last edited by
      #2

      @Mr-Pang
      simply set it on obj? :)

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on 18 Oct 2016, 12:27 last edited by A Former User
        #3

        Hi! Either like this:

        var obj = compoment.createObject(window, {color: "pink", "anchors.centerIn":window.contentItem})
        

        Or like that:

        var obj = compoment.createObject(window, {color: "pink"})
        obj.anchors.centerIn = window.contentItem
        
        M 1 Reply Last reply 19 Oct 2016, 01:22
        1
        • ? A Former User
          18 Oct 2016, 12:27

          Hi! Either like this:

          var obj = compoment.createObject(window, {color: "pink", "anchors.centerIn":window.contentItem})
          

          Or like that:

          var obj = compoment.createObject(window, {color: "pink"})
          obj.anchors.centerIn = window.contentItem
          
          M Offline
          M Offline
          Mr Pang
          wrote on 19 Oct 2016, 01:22 last edited by
          #4

          @Wieland
          Oh,Thanks.
          But,why this not work:
          var obj = compoment.createObject(window, {color: "pink", "anchors.centerIn":parent})

          P 1 Reply Last reply 19 Oct 2016, 05:49
          0
          • M Mr Pang
            19 Oct 2016, 01:22

            @Wieland
            Oh,Thanks.
            But,why this not work:
            var obj = compoment.createObject(window, {color: "pink", "anchors.centerIn":parent})

            P Offline
            P Offline
            p3c0
            Moderators
            wrote on 19 Oct 2016, 05:49 last edited by p3c0
            #5

            @Mr-Pang said in How to position dynamic created qml obj?:

            @Wieland
            Oh,Thanks.
            But,why this not work:
            var obj = compoment.createObject(window, {color: "pink", "anchors.centerIn":parent})

            That too will work provided the parent is valid and found in that context or you can directly pass an id of the item which it should be centered on instead of parent.

            157

            1 Reply Last reply
            1

            3/5

            18 Oct 2016, 12:27

            • Login

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