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. Animating anchors.bottom change
Forum Updated to NodeBB v4.3 + New Features

Animating anchors.bottom change

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

    Hi,

    I would like to animate when I change anchors.bottom. Like this:

    @Rectangle
    {
    color: "#444444"
    objectName: "view"

    TextInput {
        id: firstEdit
        font.family: "Lato Black"
        font.pixelSize: 26
        anchors.left: parent.left
        anchors.leftMargin: 30
        anchors.right: parent.right
        anchors.rightMargin: 30
        anchors.bottom: firstButton.top
        anchors.bottomMargin: 30
        text: qsTr("input")
    }
    
    TextInput {
        id: secondEdit
        opacity: 0
        font.family: "Lato Black"
        font.pixelSize: 26
        anchors.left: parent.left
        anchors.leftMargin: 30
        anchors.right: parent.right
        anchors.rightMargin: 30
        anchors.bottom: firstButton.top
        anchors.bottomMargin: 30
        text: "Peekaboo!"
    }
    
    Button {
        id: firstButton
        text: qsTr("Login")
        anchors.left: parent.left
        anchors.leftMargin: 30
        anchors.right: parent.right
        anchors.rightMargin: 30
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 30
        onClicked: login();
    }
    
    property variant showAnimation :
            ParallelAnimation {
        NumberAnimation { target: secondEdit; property: "opacity"; to: 1; duration: 1000; }
        NumberAnimation { target: firstEdit; property: "bottom"; to: secondEdit.top; duration: 1000 }
    
    }
    
    function onStartAnimation()
    {
        showAnimation.start();
        secondEdit.focus = true;
    }@
    

    But the anchors animation does not happen. Only the Opacity animation. What am I missing?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      -I noticed the same. You can achieve the animation if you don't use anchor but use x and y directly. I guess te problem is that your induvidual anchors are not really properties, so they can not be animated.-

      The above is nonsense, as per the excellent reply below. Use AnchorAnimation.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kxyu
        wrote on last edited by
        #3

        @NumberAnimation { target: firstEdit; property: "bottom"; to: secondEdit.top; duration: 1000 }@

        You know, that string does not have any sense. What do you expect to happen? This should make firstEdit.bottom=secondEdit.top smoothly in 1 second. But: 1) firstEdit.bottom is read-only 2) it's not a number
        So, to animate anchors change use AnchorAnimation.

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

          Thanks for the tip about AnchorAnimation. Will try that and from the looks of the documentation it's exactly what I want.

          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