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. How to get drag and drop relative URL?
Forum Updated to NodeBB v4.3 + New Features

How to get drag and drop relative URL?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
12 Posts 2 Posters 1.2k 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.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #2

    You will have to feed the urls to a c++ function that accepts QUrl and dissect your paths there.

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    1
    • K Offline
      K Offline
      KidTrent
      wrote on last edited by
      #3

      Thanks @fcarney I already did that, was just hoping there was a QML way...

      Do you have any idea why I can't drop files when running the program using Qt Creator's "Run" function?

      1 Reply Last reply
      0
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #4

        @KidTrent said in How to get drag and drop relative URL?:

        was just hoping there was a QML way...

        I created a set of QUrl related objects I exposed to QML for doing some processing.

        I am not sure what is happening with the not being able to drop. I have not seen that issue during my testing. Are you using drop keys of any kind? Are there some weird permissions going on?

        Maybe show us a barebones code that shows this problem.

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          KidTrent
          wrote on last edited by
          #5

          I opened a topic about it last night on Stackoverflow. Here's the article...

          https://stackoverflow.com/questions/67797636/qml-droparea-external-files-fails?noredirect=1#comment119835299_67797636

          Here's a summary if you don't want to go to stackoverflow :P...

          I'm trying to make it so I can drag and drop external files (from Explorer) into a region of my application and it will list some information about those files. The problem is that every time I drop them into a DropArea, the application says it's not allowed for some reason.

          I found out that if I run the application directly through the compiled EXE, instead of through Qt Creators "Run (Ctrl+R)" functionality it works as expected! That is to say, I'm able to drop files on the DropArea.... I'm just not sure why it doesn't work if it's ran using Qt Creator... Debugging will be very annoying like this, does anyone have any thoughts as to how I can make it work via Qt Creator too?

          Here is a video of what happens. https://puu.sh/HLz3S/39e98ed95d.mp4

          I'm running the following specs:

          • Windows 10 Pro
          • Qt 5.15.2 (Shown in video)
          • Qt Creator 4.15 (Shown in video)

          This is the code... everything else is default from a new Qt Quick application...

          import QtQuick 2.9
          import QtQuick.Window 2.12
          import QtQuick.Controls 2.3
          import QtQuick.Layouts 1.3
          
          Window {
              width: 640
              height: 480
          
              title: 'Accordion'
              visible: true
          
              DropArea {
                  anchors.fill: parent
                  onDropped: {
                      console.log("Dropped");
                  }
              }
          }
          
          1 Reply Last reply
          0
          • fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by fcarney
            #6
            import QtQuick 2.15
            import QtQuick.Window 2.15
            
            Window {
                width: 640
                height: 480
                visible: true
                title: qsTr("Generic Drag Test")
            
                DropArea {
                    anchors.fill: parent
            
                    onDropped: {
                        console.log("Dropped");
                    }
                }
            }
            

            Tested on windows 10 and ubuntu 18.04. It drops fine when running application from qt creator. I used the 5.15.2 kit in both instances. I dragged a text file from the desktop in both cases.

            C++ is a perfectly valid school of magic.

            K 1 Reply Last reply
            0
            • fcarneyF fcarney
              import QtQuick 2.15
              import QtQuick.Window 2.15
              
              Window {
                  width: 640
                  height: 480
                  visible: true
                  title: qsTr("Generic Drag Test")
              
                  DropArea {
                      anchors.fill: parent
              
                      onDropped: {
                          console.log("Dropped");
                      }
                  }
              }
              

              Tested on windows 10 and ubuntu 18.04. It drops fine when running application from qt creator. I used the 5.15.2 kit in both instances. I dragged a text file from the desktop in both cases.

              K Offline
              K Offline
              KidTrent
              wrote on last edited by
              #7

              @fcarney Yah, from everything I've read (hours worth) everyone else is able to do it just fine too... Not sure why for whatever reason I cannot...

              1 Reply Last reply
              0
              • fcarneyF Offline
                fcarneyF Offline
                fcarney
                wrote on last edited by
                #8

                It might be a privilege issue. Are you running creator with elevated privileges?

                C++ is a perfectly valid school of magic.

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  KidTrent
                  wrote on last edited by
                  #9

                  I tried starting it by right clicking and clicking "Run as Administrator", had the same issue.... It's very annoying, I'm having to compile the code, and run the exe separately each time to test changes :/.

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    KidTrent
                    wrote on last edited by
                    #10

                    If anyone else experiences this... I found out this ONLY happens if Qt Creator is Run as Admin... Not sure why this is the case, I'd expect it the other way around. So much time wasted...

                    fcarneyF 1 Reply Last reply
                    0
                    • K KidTrent

                      If anyone else experiences this... I found out this ONLY happens if Qt Creator is Run as Admin... Not sure why this is the case, I'd expect it the other way around. So much time wasted...

                      fcarneyF Offline
                      fcarneyF Offline
                      fcarney
                      wrote on last edited by
                      #11

                      @KidTrent That link I provided explains why.

                      C++ is a perfectly valid school of magic.

                      K 1 Reply Last reply
                      0
                      • fcarneyF fcarney

                        @KidTrent That link I provided explains why.

                        K Offline
                        K Offline
                        KidTrent
                        wrote on last edited by
                        #12

                        @fcarney Oh shoot, didn't see that that was a link. Thanks!

                        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