Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-112673

Drag.imageSource example - no image on first drag

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.0
    • Documentation
    • None
    • Windows 11 22H2 (Build 22621.1413)
      Qt 6.5.0/6.4.2
      ninja 1.11.0
      cmake 3.24.2
    • Windows

    Description

      The following example from the documentation does not work as expected.

      The image of the dragged item only is not visible on the first drag, after that first drag it is always visible.

      Drag.imageSource

      import QtQuick 2.12
      
      Item {
          width: 200; height: 200
      
          Rectangle {
              anchors.centerIn: parent
              width: text.implicitWidth + 20; height: text.implicitHeight + 10
              color: "green"
              radius: 5
      
              Drag.active: dragHandler.active
              Drag.dragType: Drag.Automatic
              Drag.supportedActions: Qt.CopyAction
              Drag.mimeData: {
                  "text/plain": "Copied text"
              }
      
              Text {
                  id: text
                  anchors.centerIn: parent
                  text: "Drag me"
              }
      
              DragHandler {
                  id: dragHandler
                  onActiveChanged:
                      if (active) {
                          parent.grabToImage(function(result) {
                              parent.Drag.imageSource = result.url;
                          })
                      }
              }
          }
      } 

      It also tested the same way on Qt 6.4.2.

       

      Maybe the example is meant to show that this does not work:

      Changing this property after the drag operation has started will have no effect. 

      Attachments

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Marscho Marscho
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: