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. What is the default anchoring position of an item to a view/screen?
Forum Updated to NodeBB v4.3 + New Features

What is the default anchoring position of an item to a view/screen?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 546 Views 1 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.
  • N Offline
    N Offline
    Nitheesh
    wrote on last edited by
    #1
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Rectangle{
            id: rec
            color: "red"
            width: 250
            height: 150
            visible: true
        }
    }
    

    In the above code, what would be the default anchor position w.r.t top, right, left and bottom ?
    Actually in the above example, i am unable to understand whether x,y values are considered for positioning or is it anchors that are taking care of positioning: which has the most priority over qml element positioning?

    What exactly would be the difference between anchors and x,y"

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You don't have any anchors defined in the code you pasted, so no anchoring is done at all. Position is determined solely by x,y. Both x and y have value of 0 (zero) by default.

      What exactly would be the difference between anchors and x,y"

      x and y determine position away from parent's top-left corner. If you move the parent, these coordinates will not be updated.

      anchors determine where an item is "hooked into" it's parent. When the parent moves, an anchored child will move as well.

      (Z(:^

      N 1 Reply Last reply
      3
      • N Offline
        N Offline
        Nitheesh
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • sierdzioS sierdzio

          You don't have any anchors defined in the code you pasted, so no anchoring is done at all. Position is determined solely by x,y. Both x and y have value of 0 (zero) by default.

          What exactly would be the difference between anchors and x,y"

          x and y determine position away from parent's top-left corner. If you move the parent, these coordinates will not be updated.

          anchors determine where an item is "hooked into" it's parent. When the parent moves, an anchored child will move as well.

          N Offline
          N Offline
          Nitheesh
          wrote on last edited by
          #4

          @sierdzio Thanks a lot!!

          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