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. MouseArea drag group, and drag signals
QtWS25 Last Chance

MouseArea drag group, and drag signals

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 1.1k 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.
  • P Offline
    P Offline
    pderocco
    wrote on 6 Nov 2018, 20:38 last edited by
    #1

    How do I attach handlers like onDragStarted when I'm using the drag group of properties in a MouseArea object? Within the MouseArea, onDragStarted is undefined, and drag.onDragStarted is undefined. If I refer to Drag.onDragStarted, it's not undefined, but it's never called.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 7 Nov 2018, 06:17 last edited by
      #2

      drag in mouse area is group property. It is not of type Drag. If you would like to catch drag signal, attach Drag property to an Items to be dragged. Inside the Item to be dragged use the onDragStarted.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      P 1 Reply Last reply 7 Nov 2018, 09:19
      0
      • D dheerendra
        7 Nov 2018, 06:17

        drag in mouse area is group property. It is not of type Drag. If you would like to catch drag signal, attach Drag property to an Items to be dragged. Inside the Item to be dragged use the onDragStarted.

        P Offline
        P Offline
        pderocco
        wrote on 7 Nov 2018, 09:19 last edited by
        #3

        @dheerendra
        Okay, I've added a Drag property to the Rectangle I'm trying to drag, as described in http://doc.qt.io/qt-5/qml-qtquick-drag.html#details, and added a Drag.onDragStarted handler to the Rectangle. It's not being invoked.

        So I decided to experiment with Drag.dragType. If I set it to Drag.None or Drag.Internal, the dragging works, but I don't get the signal. But if I set it to Drag.Automatic, then I get the signal, but dragging doesn't work. Instead, the mouse pointer turns into a ForbiddenCursor, and the Rectangle just jumps to the new location when the mouse button is released.

        Any more ideas?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 7 Nov 2018, 15:25 last edited by
          #4

          Just to make it work, you can check for onXChanged of corresponding items to be dragged.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Aleksey_K
            wrote on 3 Mar 2020, 05:48 last edited by
            #5

            I solved this issue by adding explicit dragActive property to the MouseArea. Sample code:

            MouseArea {
                id: mouseArea
                drag {
                    target: myItem
                    axis: Drag.YAxis
                }
                
                property bool dragActive: drag.active
                
                onDragActiveChanged: {
                    if(drag.active) { //
                        ... // Dragging started
                    } else {
                        ... // Dragging finished
                    }
                }
            }
            
            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