Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Get file info when dropping a file in DropArea

    QML and Qt Quick
    3
    3
    2556
    Loading More Posts
    • 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.
    • A
      apap_ last edited by

      Hi all,

      I have a DropArea in my QML app and I would like to drag and drop an external file in my app (in order to get the file path).
      The drop event works but I cannot find how to get file data from drop/drag event ...
      Any idea ?

      @
      Rectangle {
      width: 300;
      height: 300;

          DropArea {
              id: dropArea;
              anchors.fill: parent;
              
              onDropped: {
                  console.log ("onDropped");
                  console.log(drag);
                  console.log(drop);
              }
          }
      }
      

      @

      1 Reply Last reply Reply Quote 0
      • J
        JapieKrekel last edited by

        I'm not sure if this is possible yet.
        See "bug report":https://bugreports.qt-project.org/browse/QTBUG-27125

        1 Reply Last reply Reply Quote 0
        • M
          melghawi last edited by

          The DropArea component uses the QQuickDropEvent class which does not give access to mime data like the QDropEvent class does. Why don't you try creating your own custom qml component and override the dropEvent function which uses the QDropEvent class. That way you would have access to the file path.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post