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. Remove delay in QML element movement
Forum Updated to NodeBB v4.3 + New Features

Remove delay in QML element movement

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 299 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.
  • Q Offline
    Q Offline
    qcoderpro
    wrote on last edited by qcoderpro
    #1
    Rectangle {
            id: redBox
            width: 50; height: 50
            color: "black"
            border.width: 4
            border.color: "red"
        }
    
        MouseArea {
            anchors.fill: parent
            hoverEnabled: true
            onPositionChanged: (mouse)=> {
                redBox.x = mouse.x - redBox.width/2
                redBox.y = mouse.y - redBox.height/2
            }
        }
    }
    

    What to change so that when mouse movement is very fast redBox follows it at that speed?
    When mouse movements is very fast, there's a little delay until the redBox reaches the mouse position.

    Q 1 Reply Last reply
    0
    • Q qcoderpro
      Rectangle {
              id: redBox
              width: 50; height: 50
              color: "black"
              border.width: 4
              border.color: "red"
          }
      
          MouseArea {
              anchors.fill: parent
              hoverEnabled: true
              onPositionChanged: (mouse)=> {
                  redBox.x = mouse.x - redBox.width/2
                  redBox.y = mouse.y - redBox.height/2
              }
          }
      }
      

      What to change so that when mouse movement is very fast redBox follows it at that speed?
      When mouse movements is very fast, there's a little delay until the redBox reaches the mouse position.

      Q Offline
      Q Offline
      qcoderpro
      wrote on last edited by
      #2

      Shouldn't I use PropertyAction?
      PropertyAction - Specifies immediate property changes during animation

      JoeCFDJ 1 Reply Last reply
      0
      • Q qcoderpro

        Shouldn't I use PropertyAction?
        PropertyAction - Specifies immediate property changes during animation

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        @qcoderpro I feel like you may need a timer to reduce the number of updates of redBox.x and redBox.y if the mouse moves too fast. This means you skip some position changes of mouse.

        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