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. Qt 5.10 Drag and drop

Qt 5.10 Drag and drop

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
13 Posts 3 Posters 3.4k 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.
  • E Offline
    E Offline
    Entrevrak
    wrote on last edited by
    #1

    Hi,

    I have a problem with my drag and drop system since I built my project with Qt 5.10.

    My dragged object is still in a dragging state even after the event "dragFinished" is called. So if I do another drag move anywhere in my window it will redo the drag and drop of my object mentioned before.

    I wonder if I have to use the new DragHandler qml object. If it's a bug coming from Qt 5.10. Or if I did it wrong and it worked fine by some way with Qt 5.9.3.

    Thanks.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      Hi and welcome to devnet,

      If you can create a minimal compilable example that shows the difference of behaviour between the two Qt versions then you may have found something.

      You can also check the bug report system.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • E Offline
        E Offline
        Entrevrak
        wrote on last edited by
        #3

        Thank you for answering and welcoming me :)

        I found this bug that could be related to mine.

        Here is a minimal code that reproduce my problem:

        import QtQuick 2.7
        import QtQuick.Controls 2.0
        
        ApplicationWindow {
            visible: true
            width: 640
            height: 480
            title: qsTr("Hello World")
        
            Rectangle {
                id: container
                anchors.fill: parent
                color: "#fefefe"
                width: 640
                height: 480
                DropArea{
                    id: dropArea
                    anchors.fill: parent
                    onDropped: console.log("drop handler")
                }
        
                MouseArea {
                    id: mouseArea
                    drag.target: dragButton
                    drag.axis: Drag.XAndYAxis
                    anchors.right: parent.right
                    anchors.top: parent.top
                    width: 80
                    height: 80
                    Rectangle {
                        id: dragButton
                        color: "#ff0000"
                        anchors.fill: parent
                        Drag.active: mouseArea.drag.active
                        Drag.dragType: Drag.Automatic
                    }
                }
                states: [
                    State {
                        name: "dragState"
                        when: dropArea.containsDrag
                        PropertyChanges {
                            target: container
                            color: "#777777"
                        }
                    }
                ]
            }
        }
        
        ODБOïO 2 Replies Last reply
        0
        • E Entrevrak

          Thank you for answering and welcoming me :)

          I found this bug that could be related to mine.

          Here is a minimal code that reproduce my problem:

          import QtQuick 2.7
          import QtQuick.Controls 2.0
          
          ApplicationWindow {
              visible: true
              width: 640
              height: 480
              title: qsTr("Hello World")
          
              Rectangle {
                  id: container
                  anchors.fill: parent
                  color: "#fefefe"
                  width: 640
                  height: 480
                  DropArea{
                      id: dropArea
                      anchors.fill: parent
                      onDropped: console.log("drop handler")
                  }
          
                  MouseArea {
                      id: mouseArea
                      drag.target: dragButton
                      drag.axis: Drag.XAndYAxis
                      anchors.right: parent.right
                      anchors.top: parent.top
                      width: 80
                      height: 80
                      Rectangle {
                          id: dragButton
                          color: "#ff0000"
                          anchors.fill: parent
                          Drag.active: mouseArea.drag.active
                          Drag.dragType: Drag.Automatic
                      }
                  }
                  states: [
                      State {
                          name: "dragState"
                          when: dropArea.containsDrag
                          PropertyChanges {
                              target: container
                              color: "#777777"
                          }
                      }
                  ]
              }
          }
          
          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • E Entrevrak

            Thank you for answering and welcoming me :)

            I found this bug that could be related to mine.

            Here is a minimal code that reproduce my problem:

            import QtQuick 2.7
            import QtQuick.Controls 2.0
            
            ApplicationWindow {
                visible: true
                width: 640
                height: 480
                title: qsTr("Hello World")
            
                Rectangle {
                    id: container
                    anchors.fill: parent
                    color: "#fefefe"
                    width: 640
                    height: 480
                    DropArea{
                        id: dropArea
                        anchors.fill: parent
                        onDropped: console.log("drop handler")
                    }
            
                    MouseArea {
                        id: mouseArea
                        drag.target: dragButton
                        drag.axis: Drag.XAndYAxis
                        anchors.right: parent.right
                        anchors.top: parent.top
                        width: 80
                        height: 80
                        Rectangle {
                            id: dragButton
                            color: "#ff0000"
                            anchors.fill: parent
                            Drag.active: mouseArea.drag.active
                            Drag.dragType: Drag.Automatic
                        }
                    }
                    states: [
                        State {
                            name: "dragState"
                            when: dropArea.containsDrag
                            PropertyChanges {
                                target: container
                                color: "#777777"
                            }
                        }
                    ]
                }
            }
            
            ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by
            #5

            @Entrevrak Hello, I think if you use Connexion insted of binding (onDropped ) it will work again.

            E 1 Reply Last reply
            0
            • ODБOïO ODБOï

              @Entrevrak Hello, I think if you use Connexion insted of binding (onDropped ) it will work again.

              E Offline
              E Offline
              Entrevrak
              wrote on last edited by
              #6

              @LeLev Hello,

              If you meant:

              Connections {
                          target: dropArea
                          onDropped: {
                              console.log("drop handler")
                          }
                      }
              

              No it does not work.

              ODБOïO 1 Reply Last reply
              0
              • E Entrevrak

                @LeLev Hello,

                If you meant:

                Connections {
                            target: dropArea
                            onDropped: {
                                console.log("drop handler")
                            }
                        }
                

                No it does not work.

                ODБOïO Offline
                ODБOïO Offline
                ODБOï
                wrote on last edited by
                #7

                @Entrevrak then sorry :/ i don't have auther idea

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Can you describe what should happen ?

                  On my system with both 5.10 and 5.8 (using qmlscene to run your sample) I have a red square that doesn't move but the onDropped slot gets called.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    Entrevrak
                    wrote on last edited by
                    #9

                    Sorry I hope my next explanation will be better.

                    The only thing my sample code should do is on drag and drop from the red square to the dropArea.

                    But in Qt 5.10, I can keep doing drag and drop event from anywhere in the window.

                    Here is a gif showing the problem:

                    0_1513239774855_dragDropBug.gif

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Ok, so just to be sure:

                      • Drag the red square once
                      • Drop
                      • Drag can now be done from anywhere else

                      Is that correct ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        Entrevrak
                        wrote on last edited by
                        #11

                        Yes, correct.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Then I don’t have that behavior on macOS with my 5.10 build.

                          I’ll check with the official release.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • E Offline
                            E Offline
                            Entrevrak
                            wrote on last edited by
                            #13

                            You're right I tested out on macOS and the problem wasn't there.
                            I tried on Windows 7 and Windows 10 and both have the problem.

                            Thanks for the info, I did not thought of testing on another OS.

                            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