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. Lock children inside parent

Lock children inside parent

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.2k 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.
  • H Offline
    H Offline
    Hykkel
    wrote on last edited by
    #1

    Hi.

    I'm trying to make a drop down animation. I face the problem that the child rectangle is showed on top, and hence outside the parent rectangle. Is it not possible to have the children "inside" the parent??

    In the below code, the redRect is always visible. The animation works fine (except the fact that the red square is always shown).

    @import QtQuick 2.0

    Rectangle {
    width: 100
    height: 10

    Behavior on height { NumberAnimation { easing.type: Easing.OutQuad; duration: 400 } }
    
    function hide()
    {
        height = 0;
    }
    
    function show()
    {
        height = childrenRect.height
    
    }
    
    Rectangle {
        id: redSquare
        width: 50; height: 50
        color: "red"
    }
    

    }@

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hykkel
      wrote on last edited by
      #2

      Solved this issue by adding a dummy rectangle that anchors to the bottom of the "dowp down" (in the qml file that uses the above "dropdown" file).

      YES that's right - it now works :)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Adrien Leravat
        wrote on last edited by
        #3

        Hi Hykkel,

        If I understand right, what your are looking for is the "clip" property. It ensures that children are visible only inside parent surface.

        @
        import QtQuick 2.0

        Rectangle {
        clip: true
        ...
        }@

        Note that this clipping test costs CPU usage.

        Regards

        Adeneo Embedded - www.adeneo-embedded.com

        1 Reply Last reply
        0
        • H Offline
          H Offline
          Hykkel
          wrote on last edited by
          #4

          That was it!!

          Thanks a lot... I sure did hate that dummy rectangle hack I made!

          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