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. Enable another application's window to be dragged and dropped onto my widget ?
Forum Updated to NodeBB v4.3 + New Features

Enable another application's window to be dragged and dropped onto my widget ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 354 Views 3 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.
  • L Offline
    L Offline
    LinuxGuy
    wrote on last edited by
    #1

    I would like to build a widget wherein I can drag another application's window onto my widget and drop it. My widget will then do things with the other window such as minimize, move it, etc.

    How do I sense when the other application is dropped on my widget ? I have drag and drop working for text file, etc. but it doesn't work for another window, probably because the other window receives the mouse events of the drop, not my widget.

    Is there a way to capture a drag and drop event for the desktop from my widget ?

    Once the other application's window is dropped on my widget, I need to get the handle of the other window. How do I do that ?

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      In the scenario you describe, there is no drag and drop happening at the application level.

      You have a different application which has the focus and which window is moved around on the desktop. Your own application will not receive any specific events related to that beside repainting itself because something has changed in its visibility and that will also depend on the window manager you use.

      If there's anything that can be done, you should check that at the WM level to see if there's a protocol that allows this kind of communication.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply
      3
      • SGaistS SGaist

        Hi and welcome to devnet,

        In the scenario you describe, there is no drag and drop happening at the application level.

        You have a different application which has the focus and which window is moved around on the desktop. Your own application will not receive any specific events related to that beside repainting itself because something has changed in its visibility and that will also depend on the window manager you use.

        If there's anything that can be done, you should check that at the WM level to see if there's a protocol that allows this kind of communication.

        L Offline
        L Offline
        LinuxGuy
        wrote on last edited by LinuxGuy
        #3

        @SGaist I figured that. Thanks for the reply.

        What if one sensed the position of the mouse outside the application, figure out if it stops over the application's area and if a window is then overlapping the application ? Could that be done ?

        If dragging and dropping a window like that does happen at the WM level, how do I pass that into my PyQt application ?

        JonBJ 1 Reply Last reply
        0
        • L LinuxGuy

          @SGaist I figured that. Thanks for the reply.

          What if one sensed the position of the mouse outside the application, figure out if it stops over the application's area and if a window is then overlapping the application ? Could that be done ?

          If dragging and dropping a window like that does happen at the WM level, how do I pass that into my PyQt application ?

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @LinuxGuy
          I think it is not easy to see the mouse outside of your application windows. Might have to "grab" the mouse, which is not pretty and can leave window system unstable, might be able to "poll" on a timer (https://stackoverflow.com/a/29400627/489865). Google for qt mouse outside application. Then there is the complication that the windowing system is in the middle of a window-drag operation, which can only make it harder, and you want to detect drop as well. And if you are using Wayland wouldn't surprise me if it stops you doing this (I have no evidence for this, just that it sounds like what it would want to prevent).

          Can you name an application, other than something in the window manager itself, which does what you are wanting to do?

          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