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. QML DropArea: drop an external file does not work
QtWS25 Last Chance

QML DropArea: drop an external file does not work

Scheduled Pinned Locked Moved Solved QML and Qt Quick
14 Posts 3 Posters 5.4k 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.
  • Diego DonateD Offline
    Diego DonateD Offline
    Diego Donate
    wrote on last edited by
    #1

    Hi,

    I have a QML application and I would like to enable an area to drop there an external file (dragged from Windows explorer, for instance) and show the file path in my application.

    I have a really simple test qml to try, but I can not drop anything ("not accepted" cursor is displayed when I enter my DropArea dragging the file).

    My code:

    import QtQuick 2.1
    import QtQuick.Controls 1.0
    
    ApplicationWindow {
        title: qsTr("Drop Area test")
    
        width: 800
        height: 600
    
        visible: true
    
        DropArea {
            id: drop
            anchors.fill: parent
    
            enabled: true
    
            onEntered:
                console.log("entered");
    
            onExited:
                console.log("exited")
    
            onDropped:
                console.log("dropped")
        }
    
        Text {
            id: textDrop
            anchors.centerIn: parent
            text: "Drop an element"
        }
    }
    

    I supponse I am doing anything wrong, but I can not fix it...

    Thanks in advance

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Diego-Donate There was a bug reported but it is Linux specific. Looks like it was not solved for Windows. Which Qt version did you try ?

      157

      Diego DonateD 1 Reply Last reply
      0
      • p3c0P p3c0

        @Diego-Donate There was a bug reported but it is Linux specific. Looks like it was not solved for Windows. Which Qt version did you try ?

        Diego DonateD Offline
        Diego DonateD Offline
        Diego Donate
        wrote on last edited by
        #3

        @p3c0 I tried with QT 5.7

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @Diego-Donate Well then you should report new one. And mention the OS and Qt version.

          157

          Diego DonateD 1 Reply Last reply
          0
          • p3c0P p3c0

            @Diego-Donate Well then you should report new one. And mention the OS and Qt version.

            Diego DonateD Offline
            Diego DonateD Offline
            Diego Donate
            wrote on last edited by
            #5

            @p3c0 Have you tried my code? I thought it is so simple that it should work... I could not imagine it is a QT bug!! :(

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by p3c0
              #6

              @Diego-Donate You can try the official example:
              http://doc.qt.io/qt-5/qtquick-externaldraganddrop-example.html

              Try dropping external file into the second tile. If it succeeds it will display the file name.

              It works on Ubuntu 14.04 with Qt 5.6

              157

              Diego DonateD 1 Reply Last reply
              0
              • p3c0P p3c0

                @Diego-Donate You can try the official example:
                http://doc.qt.io/qt-5/qtquick-externaldraganddrop-example.html

                Try dropping external file into the second tile. If it succeeds it will display the file name.

                It works on Ubuntu 14.04 with Qt 5.6

                Diego DonateD Offline
                Diego DonateD Offline
                Diego Donate
                wrote on last edited by
                #7

                @p3c0 Ok, the example does not work for me in Windows 7 (QT 5.7)... I can drag and drop text from one tile to another inside the window, but nothing happens if i drag a file or text from out of the application...

                I will notify it in case it is a bug... can it be??

                1 Reply Last reply
                0
                • p3c0P Offline
                  p3c0P Offline
                  p3c0
                  Moderators
                  wrote on last edited by
                  #8

                  @Diego-Donate According to me, yes, it is a bug.

                  157

                  Diego DonateD 1 Reply Last reply
                  0
                  • p3c0P p3c0

                    @Diego-Donate According to me, yes, it is a bug.

                    Diego DonateD Offline
                    Diego DonateD Offline
                    Diego Donate
                    wrote on last edited by
                    #9

                    @p3c0 The official example works for me when I drag and drop text from outside the application, but nothing happens when I try to drag a file, should it show the file name? Or it is only for text?

                    1 Reply Last reply
                    0
                    • p3c0P Offline
                      p3c0P Offline
                      p3c0
                      Moderators
                      wrote on last edited by
                      #10

                      @Diego-Donate

                      should it show the file name?

                      Yes.

                      157

                      Diego DonateD 1 Reply Last reply
                      0
                      • p3c0P p3c0

                        @Diego-Donate

                        should it show the file name?

                        Yes.

                        Diego DonateD Offline
                        Diego DonateD Offline
                        Diego Donate
                        wrote on last edited by
                        #11

                        @p3c0 Thanks for your time. It seemed to be something related to my QT installation, I reinstalled QT package and now it works... I don't know why!!!

                        1 Reply Last reply
                        0
                        • p3c0P Offline
                          p3c0P Offline
                          p3c0
                          Moderators
                          wrote on last edited by
                          #12

                          @Diego-Donate Glad to know that it works on Windows with Qt 5.7. Did you also check the official example ?

                          157

                          Diego DonateD 1 Reply Last reply
                          0
                          • p3c0P p3c0

                            @Diego-Donate Glad to know that it works on Windows with Qt 5.7. Did you also check the official example ?

                            Diego DonateD Offline
                            Diego DonateD Offline
                            Diego Donate
                            wrote on last edited by
                            #13

                            @p3c0 Yes, it is the same, I am not sure why but now I have it all working... Thanks a lot

                            1 Reply Last reply
                            0
                            • V Offline
                              V Offline
                              veiky
                              wrote on last edited by
                              #14

                              I meet the same problem on Qt.5.9 + Win10SDK + MSVS buildtools 2015

                              drop file on DropArea nothing happened

                              drop text on DropArea sure working

                              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