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 actually "contain" Items
QtWS25 Last Chance

How to actually "contain" Items

Scheduled Pinned Locked Moved Solved QML and Qt Quick
containersqmlrectangles
3 Posts 2 Posters 1.4k 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.
  • M Offline
    M Offline
    Mark81
    wrote on 2 Jun 2016, 18:12 last edited by
    #1

    Consider this short code:

    Rectangle {
            anchors.centerIn: parent
            color: "red"
            width: 100
            height: 100
    
            Rectangle {
                anchors.left: parent.horizontalCenter
                anchors.top: parent.verticalCenter
                width: 100
                height: 100
                color: "green"
            }
        }
    

    It draws two squares. The top-left corner of the green square is placed in the center of the red one:

    http://picpaste.com/pics/rect2985-1-037CdPPL.1464890945.png

    I want the inner elements are "trimmed" by the container. So this is what I expect:

    http://picpaste.com/pics/rect2985-1-Sx7qer9d.1464891040.png

    I make the example using two rects, but the question is open to any QML Types.

    M 1 Reply Last reply 3 Jun 2016, 02:19
    0
    • M Mark81
      2 Jun 2016, 18:12

      Consider this short code:

      Rectangle {
              anchors.centerIn: parent
              color: "red"
              width: 100
              height: 100
      
              Rectangle {
                  anchors.left: parent.horizontalCenter
                  anchors.top: parent.verticalCenter
                  width: 100
                  height: 100
                  color: "green"
              }
          }
      

      It draws two squares. The top-left corner of the green square is placed in the center of the red one:

      http://picpaste.com/pics/rect2985-1-037CdPPL.1464890945.png

      I want the inner elements are "trimmed" by the container. So this is what I expect:

      http://picpaste.com/pics/rect2985-1-Sx7qer9d.1464891040.png

      I make the example using two rects, but the question is open to any QML Types.

      M Offline
      M Offline
      medyakovvit
      wrote on 3 Jun 2016, 02:19 last edited by
      #2

      @Mark81 I think, property clip is what you need.

      M 1 Reply Last reply 3 Jun 2016, 06:58
      1
      • M medyakovvit
        3 Jun 2016, 02:19

        @Mark81 I think, property clip is what you need.

        M Offline
        M Offline
        Mark81
        wrote on 3 Jun 2016, 06:58 last edited by
        #3

        @medyakovvit exactly what I need! Thanks a lot

        1 Reply Last reply
        0

        3/3

        3 Jun 2016, 06:58

        • Login

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