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 snap Item to center when item dragged(drag started)
Qt 6.11 is out! See what's new in the release blog

How to snap Item to center when item dragged(drag started)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.2k Views 2 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.
  • W Offline
    W Offline
    W.Y.Kim
    wrote on last edited by
    #1

    Hello Everyone!

    I have a doubt with draggin items.

    I want to change Item position when drag started.

    If drag started, the item should be moved mouse point.
    It means If I drag item by edge of item, then Item's center should be moved mouse press point.

    How can I do ?

    I used to State( when : drag.active --> PropertyChanges x , y), but It was not working properly

    Please give me the tip.
    Regards

    1 Reply Last reply
    0
    • jpnurmiJ Offline
      jpnurmiJ Offline
      jpnurmi
      wrote on last edited by
      #2

      See Drag.hotSpot.

      W 1 Reply Last reply
      1
      • jpnurmiJ jpnurmi

        See Drag.hotSpot.

        W Offline
        W Offline
        W.Y.Kim
        wrote on last edited by W.Y.Kim
        #3

        @jpnurmi Thanks for reply.
        But It doesn't work. I mean, Item should be move to touch point.

        drag.hotspot is just the point of action, Am i right?

        ++
        I solved this issue
        I use onPositionChanged.

        onPositionChanged:{
        if(drag.active){
        item.x = mouse.x
        item.y = mouse.y
        }

        Thanks a lot!

        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