Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt applications cannot drag and drop files when running under Windows with administrator rights.
QtWS25 Last Chance

Qt applications cannot drag and drop files when running under Windows with administrator rights.

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 4 Posters 2.1k 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.
  • L Offline
    L Offline
    lwei2
    wrote on 15 Oct 2021, 10:00 last edited by
    #1

    Hello, everyone, in the Qt application, the implementation of drag and drop function, but if compiled as an administrator to run the application, found that drag and drop function does not work, I do not know if you have encountered such a problem? Is there any solution to this problem?

    J 1 Reply Last reply 15 Oct 2021, 10:18
    0
    • L lwei2
      15 Oct 2021, 10:00

      Hello, everyone, in the Qt application, the implementation of drag and drop function, but if compiled as an administrator to run the application, found that drag and drop function does not work, I do not know if you have encountered such a problem? Is there any solution to this problem?

      J Offline
      J Offline
      JonB
      wrote on 15 Oct 2021, 10:18 last edited by
      #2

      @lwei2
      I do not believe this has anything to do with Qt. IIRC, Windows behaviour is indeed to forbid d&d between user programs and admin-elevated-programs, at least in one direction or the other, for security reasons. You should look that up on the web.

      BTW, what does "but if compiled as an administrator to run the application". "Compiled" as an administrator? I don't see the relevance. You do mean run as an administrator, don't you?

      L 2 Replies Last reply 15 Oct 2021, 10:23
      0
      • J JonB
        15 Oct 2021, 10:18

        @lwei2
        I do not believe this has anything to do with Qt. IIRC, Windows behaviour is indeed to forbid d&d between user programs and admin-elevated-programs, at least in one direction or the other, for security reasons. You should look that up on the web.

        BTW, what does "but if compiled as an administrator to run the application". "Compiled" as an administrator? I don't see the relevance. You do mean run as an administrator, don't you?

        L Offline
        L Offline
        lwei2
        wrote on 15 Oct 2021, 10:23 last edited by
        #3

        @JonB hi,If you run an application with administrator privileges, is there any way to allow the application to drag and drop files?

        1 Reply Last reply
        0
        • J JonB
          15 Oct 2021, 10:18

          @lwei2
          I do not believe this has anything to do with Qt. IIRC, Windows behaviour is indeed to forbid d&d between user programs and admin-elevated-programs, at least in one direction or the other, for security reasons. You should look that up on the web.

          BTW, what does "but if compiled as an administrator to run the application". "Compiled" as an administrator? I don't see the relevance. You do mean run as an administrator, don't you?

          L Offline
          L Offline
          lwei2
          wrote on 15 Oct 2021, 10:41 last edited by
          #4

          If you use Qt to develop applications for others to use, once someone else runs the Qt application with administrator rights, the original drag-and-drop function will not work under administrator rights, which can be mistaken as a problem. Therefore, I wanted to find a way to run Qt applications under administrator privileges while still dragging and dropping files.

          J 1 Reply Last reply 15 Oct 2021, 10:54
          0
          • L lwei2
            15 Oct 2021, 10:41

            If you use Qt to develop applications for others to use, once someone else runs the Qt application with administrator rights, the original drag-and-drop function will not work under administrator rights, which can be mistaken as a problem. Therefore, I wanted to find a way to run Qt applications under administrator privileges while still dragging and dropping files.

            J Offline
            J Offline
            JonB
            wrote on 15 Oct 2021, 10:54 last edited by
            #5

            @lwei2
            Like I said, I don't see this has anything at all to do with Qt. It's a Windows thing for applications, no matter what toolchain or language they are written with. Have you done as I suggested and investigated this on the web?

            L 1 Reply Last reply 15 Oct 2021, 12:00
            0
            • J JonB
              15 Oct 2021, 10:54

              @lwei2
              Like I said, I don't see this has anything at all to do with Qt. It's a Windows thing for applications, no matter what toolchain or language they are written with. Have you done as I suggested and investigated this on the web?

              L Offline
              L Offline
              lwei2
              wrote on 15 Oct 2021, 12:00 last edited by
              #6

              @JonB I have checked this problem on the Internet. Although it is the behavior of Windows for security reasons, I also tried to find the interface related to Windows to solve this problem. But nothing worked. The question is not what Qt has to do with it, but is there a way for Qt to prevent dragging and dropping files due to administrator permissions?

              J 1 Reply Last reply 15 Oct 2021, 12:12
              0
              • L lwei2
                15 Oct 2021, 12:00

                @JonB I have checked this problem on the Internet. Although it is the behavior of Windows for security reasons, I also tried to find the interface related to Windows to solve this problem. But nothing worked. The question is not what Qt has to do with it, but is there a way for Qt to prevent dragging and dropping files due to administrator permissions?

                J Offline
                J Offline
                JonB
                wrote on 15 Oct 2021, 12:12 last edited by JonB
                #7

                @lwei2 said in Qt applications cannot drag and drop files when running under Windows with administrator rights.:

                The question is not what Qt has to do with it, but is there a way for Qt to prevent dragging and dropping files due to administrator permissions?

                As I have tried to answer several times, since indeed Qt has nothing to do with it and it is an intended OS behaviour, Qt cannot alter the behaviour of Windows.

                I also tried to find the interface related to Windows to solve this problem. But nothing worked.

                Don't know what that means.

                If you want to find out what the web says about how this can be achieved in a Windows application, come back and tell us and we will see if there is anything to be done.

                BTW, you have never said what you are d&d'ing between, and in which direction. I believe other than your application the other one is Windows File Explorer? Or not? Which are the two applications, which of the two is running elevated, and in which direction are you d&d'ing? But answering this does should not stop you doing your own investigations as to what the web says can be done about it.

                L 1 Reply Last reply 15 Oct 2021, 12:27
                0
                • J JonB
                  15 Oct 2021, 12:12

                  @lwei2 said in Qt applications cannot drag and drop files when running under Windows with administrator rights.:

                  The question is not what Qt has to do with it, but is there a way for Qt to prevent dragging and dropping files due to administrator permissions?

                  As I have tried to answer several times, since indeed Qt has nothing to do with it and it is an intended OS behaviour, Qt cannot alter the behaviour of Windows.

                  I also tried to find the interface related to Windows to solve this problem. But nothing worked.

                  Don't know what that means.

                  If you want to find out what the web says about how this can be achieved in a Windows application, come back and tell us and we will see if there is anything to be done.

                  BTW, you have never said what you are d&d'ing between, and in which direction. I believe other than your application the other one is Windows File Explorer? Or not? Which are the two applications, which of the two is running elevated, and in which direction are you d&d'ing? But answering this does should not stop you doing your own investigations as to what the web says can be done about it.

                  L Offline
                  L Offline
                  lwei2
                  wrote on 15 Oct 2021, 12:27 last edited by
                  #8

                  @JonB Currently, I use the Qt framework to develop applications. Of course, I would like Qt to be able to still drag and drop files in applications running under administrator rights, but in fact, Qt doesn't seem to have a way to do that. Therefore, I had to look for Windows interfaces to solve this problem. Just as you develop software for others to use, you can't let others not use administrator privileges. As you mentioned, the inability to drag and drop files when Qt applications run with administrator privileges is a Windows issue and has nothing to do with Qt. Even so, many people who use software will assume that Qt's inability to implement is a problem, not a Windows problem.

                  jsulmJ J 2 Replies Last reply 15 Oct 2021, 12:31
                  0
                  • L lwei2
                    15 Oct 2021, 12:27

                    @JonB Currently, I use the Qt framework to develop applications. Of course, I would like Qt to be able to still drag and drop files in applications running under administrator rights, but in fact, Qt doesn't seem to have a way to do that. Therefore, I had to look for Windows interfaces to solve this problem. Just as you develop software for others to use, you can't let others not use administrator privileges. As you mentioned, the inability to drag and drop files when Qt applications run with administrator privileges is a Windows issue and has nothing to do with Qt. Even so, many people who use software will assume that Qt's inability to implement is a problem, not a Windows problem.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 15 Oct 2021, 12:31 last edited by
                    #9

                    @lwei2 Does your application require to run with administrator privileges? If not: why bother? Hardly anybody will explicitly start your app with administrative privileges if not needed.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    L 1 Reply Last reply 18 Oct 2021, 03:26
                    0
                    • L lwei2
                      15 Oct 2021, 12:27

                      @JonB Currently, I use the Qt framework to develop applications. Of course, I would like Qt to be able to still drag and drop files in applications running under administrator rights, but in fact, Qt doesn't seem to have a way to do that. Therefore, I had to look for Windows interfaces to solve this problem. Just as you develop software for others to use, you can't let others not use administrator privileges. As you mentioned, the inability to drag and drop files when Qt applications run with administrator privileges is a Windows issue and has nothing to do with Qt. Even so, many people who use software will assume that Qt's inability to implement is a problem, not a Windows problem.

                      J Offline
                      J Offline
                      JonB
                      wrote on 15 Oct 2021, 12:43 last edited by
                      #10

                      @lwei2 said in Qt applications cannot drag and drop files when running under Windows with administrator rights.:

                      Qt doesn't seem to have a way to do that

                      Because Windows prevents it. what would like Qt to do about it? Wave a magic wand? Offer a new operating system to replace Windows?

                      Therefore, I had to look for Windows interfaces to solve this problem

                      Yes, because it's Windows behaviour, nothing to do with Qt. Only a Windows solution, if any exists, can be used.

                      Even so, many people who use software will assume that Qt's inability to implement is a problem, not a Windows problem.

                      LOL. So if, for example, OS permissions forbid a user to access a file and you happen to write a program in Java language using DirectX library, and of course this can make no difference to the fact that the OS denies access to the file, that is Java or DirectX's fault?

                      When you and your users understand the difference between an OS and a program/application your/their expectations may become more realistic. Till then, blame whatever you like.

                      The fact still remains that only something in Windows can do anything about this. When you have found out what, if anything, Windows allows in this area let us know.

                      As @jsulm has noted, goodness knows why you are in this situation. Maybe you don't need to run your application as Administrator, but we don't know, because you have not said why.

                      Anyway, if you want further help I suggest you answer the questions I asked above about which applications are involved how. Or best of luck.

                      L 1 Reply Last reply 18 Oct 2021, 02:15
                      0
                      • J JonB
                        15 Oct 2021, 12:43

                        @lwei2 said in Qt applications cannot drag and drop files when running under Windows with administrator rights.:

                        Qt doesn't seem to have a way to do that

                        Because Windows prevents it. what would like Qt to do about it? Wave a magic wand? Offer a new operating system to replace Windows?

                        Therefore, I had to look for Windows interfaces to solve this problem

                        Yes, because it's Windows behaviour, nothing to do with Qt. Only a Windows solution, if any exists, can be used.

                        Even so, many people who use software will assume that Qt's inability to implement is a problem, not a Windows problem.

                        LOL. So if, for example, OS permissions forbid a user to access a file and you happen to write a program in Java language using DirectX library, and of course this can make no difference to the fact that the OS denies access to the file, that is Java or DirectX's fault?

                        When you and your users understand the difference between an OS and a program/application your/their expectations may become more realistic. Till then, blame whatever you like.

                        The fact still remains that only something in Windows can do anything about this. When you have found out what, if anything, Windows allows in this area let us know.

                        As @jsulm has noted, goodness knows why you are in this situation. Maybe you don't need to run your application as Administrator, but we don't know, because you have not said why.

                        Anyway, if you want further help I suggest you answer the questions I asked above about which applications are involved how. Or best of luck.

                        L Offline
                        L Offline
                        lwei2
                        wrote on 18 Oct 2021, 02:15 last edited by
                        #11

                        @JonB All right, thanks!

                        1 Reply Last reply
                        0
                        • jsulmJ jsulm
                          15 Oct 2021, 12:31

                          @lwei2 Does your application require to run with administrator privileges? If not: why bother? Hardly anybody will explicitly start your app with administrative privileges if not needed.

                          L Offline
                          L Offline
                          lwei2
                          wrote on 18 Oct 2021, 03:26 last edited by
                          #12

                          @jsulm As software developers, we cannot require or avoid users to run software with administrator privileges. Therefore, if users find that the software cannot be dragged and dropped under administrator privileges, they will assume that the problem is with our software rather than Windows.

                          1 Reply Last reply
                          0
                          • xanaduX Offline
                            xanaduX Offline
                            xanadu
                            wrote on 5 Mar 2022, 09:04 last edited by
                            #13

                            What I'm trying to say is that only QT has this problem! ! !

                            call the following function
                            // application
                            ::ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
                            ::ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
                            ::ChangeWindowMessageFilter(WM_COPYGLOBALDATA, MSGFLT_ADD);

                            // window
                            ::DragAcceptFiles(HWND, TRUE);
                            ::ChangeWindowMessageFilterEx(HWND, WM_DROPFILES, MSGFLT_ALLOW, nullptr);
                            ::ChangeWindowMessageFilterEx(HWND, WM_COPYDATA, MSGFLT_ALLOW, nullptr);
                            ::ChangeWindowMessageFilterEx(HWND, WM_COPYGLOBALDATA, MSGFLT_ALLOW, nullptr);
                            When I use MFC, Win32, wxWidgets, there is no problem.

                            Only QT, called and nothing happens.
                            I don't understand, why my use of WinId doesn't work.
                            How exactly is it different from the HWND returned by CreateWindow?
                            Or, what is QT doing internally that causes these calls to fail.

                            Please don't say it's a Windows problem and not a Qt problem.
                            In fact Windows provides an API that supports drag and drop for administrators.
                            However, the window handle returned by Qt does not support this operation.
                            But Win32, MFC, etc., the returned handle can be manipulated.

                            1 Reply Last reply
                            0
                            • Cobra91151C Cobra91151 referenced this topic on 26 Aug 2023, 12:20

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved