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. Widget transparent to mouse events, except drag and drop, sometimes
Forum Updated to NodeBB v4.3 + New Features

Widget transparent to mouse events, except drag and drop, sometimes

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.1k 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.
  • W Offline
    W Offline
    wrosecrans
    wrote on last edited by
    #1

    I have a parent widget, and I have an "overlay" widget which is the last child widget of the parent. I want to have the overlay be able to draw stuff on top of the parent, and respond to some drag and drop events. So far, I have drawing the overlay working, and I am currently doing "setAttribute(Qt::WA_TransparentForMouseEvents);" so normal mouse events are being based to the underlying widgets. But, I want to allow the overlay to respond to some drags. Doing "setAcceptDrops(true);" doesn't seem to have any effect after I set it to be transparent. for events

    So, how can I make a widget that is transparent to "normal" events, but still responds to drag and drop?

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

      Hi,

      How are you doing the drag & drop ?

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

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wrosecrans
        wrote on last edited by
        #3

        After quite a bit of tinkering, I have changed the way I was doing drag and drop, and gotten it to work by not having the overlay widget responsible for anything related to the drag and drop. Instead, the overlay widget is invisible by default, and is transparent to all mouse events.

        The parent widget, however, is responsible for responding to the dragEnter/dragMove/drop events. Whenever the parent gets an enter event, it basically does overlay->showOverlay() and triggers an overlay->update() on every parent::dragMove. The result is that the overlay can show the helpful information that I want in response to drags.

        I'm not sure if this split responsibility model is the most efficient way to do it, but after a few days of tinkering, it certainly seems to work better than anything else I tried.

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

          It sure is way cleaner. Since it looks that this overlay widget responsibility is only to show additional information, then this is the correct design.

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

          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