Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Adjust translation speed of QML DragHandler
Qt 6.12 LTS is out! See what's new in the release blog

Adjust translation speed of QML DragHandler

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qml dragging
1 Posts 1 Posters 347 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.
  • L Offline
    L Offline
    laseranimation
    wrote on last edited by laseranimation
    #1

    My question is about using a QML DragHandler to move a QML Item. I have successfully implemented position through dragging (when holding the Ctrl modifier) like so:

    DragHandler {
        dragThreshold: 0
        acceptedModifiers: Qt.ControlModifier
    }
    

    Now I would like to add another handler that allows me to precisely position the element. Other software does this throught the use of the shift modifier. So what I want to do is move the element not by the pixel amount that the mouse moves, but an amount smaller than that. Ideally I would want to do something like this:

    DragHandler {
        dragThreshold: 0
        acceptedModifiers: Qt.ShiftModifier
    
        onActiveTranslationChanged: {
            activeTranslation *= 0.5;
        }
    }
    

    Unfortunatelly activeTranslation is read-only and I don't see any other property I could use and I can't think of any other way to do it... Does anybody have an idea how to acchive this?

    Thank you very much in advance!

    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
    • Unsolved