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

Drag.imageSource example - no image on first drag

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.2.11, 6.5.4, 6.6.2, 6.7.0 FF
    • 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
    • a3dea1b4f (dev), 85f6ffc9b (6.6), 9d1e8deef (tqtc/lts-6.5), b09d82e6f (tqtc/lts-6.2)

      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. 

        For Gerrit Dashboard: QTBUG-112673
        # Subject Branch Project Status CR V

            srutledg Shawn Rutledge
            Marscho Marscho
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: