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. Replacing a child widget during a drag&drop
Forum Updated to NodeBB v4.3 + New Features

Replacing a child widget during a drag&drop

Scheduled Pinned Locked Moved General and Desktop
6 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.
  • R Offline
    R Offline
    remram
    wrote on last edited by
    #1

    Hi,

    I'm writing an overlay for a custom widget, that should be displayed while dragging something on it. This overlay can contain information on what will happen if the object is dropped, or different drop zones. However, it seems that adding or removing a child widget (the overlay) during a drag causes a pair QDragLeaveEvent and QDragEnterEvent to be emitted, even though acceptDrops is false on the overlay widget.

    Because I create the child on dragEnter and remove it on dragLeave, this causes a loop that causes the overlay to flicker, and I can't handle the drop correctly.

    This issue only seems to happen on Mac OS (on Windows this works fine).

    How should I work around this issue? Is it considered safe to change child widgets during these two events?

    Thank you for your time

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

      Hello,

      Since it's an overlay widget, did you set the Qt::WA_TransparentForMouseEvents flag ? That should make your widget "invisible" for move related events.

      Hope it helps

      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
      • R Offline
        R Offline
        remram
        wrote on last edited by
        #3

        Thank you! I can set it when the overlay appears while dragging, and this fixes my problem.

        I had no idea there was a flag like this (or that "widget attributes":http://doc.qt.digia.com/qt/qwidget.html#setAttribute existed at all).

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

          I think you can set it at construction time, so your widget is "transparent" from the start.

          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
          • R Offline
            R Offline
            remram
            wrote on last edited by
            #5

            [quote author="SGaist" date="1360777331"]I think you can set it at construction time, so your widget is "transparent" from the start.[/quote]

            Yes, indeed. But this overlay is sometimes constructed during a drag (then I don't want it to interfere with mouse events) and sometimes not (then it has to respond to clicks). I am setting the flag if appropriate in my constructor. Thank you again!

            1 Reply Last reply
            0
            • R Offline
              R Offline
              remram
              wrote on last edited by
              #6

              Ok, it seems my problem is not resolved after all...

              When my widget gets a dragEnterEvent, it replaces the current overlay (a widget without WA_TransparentForMouseEvents) with another one (a widget with WA_TransparentForMouseEvents set). This works fine on Windows, but crashes (segmentation fault) on Mac OS (not even all the time...)

              If WA_TransparentForMouseEvents was set on the previous widget (the one I'm replacing) it works even on Mac OS.

              I don't understand what is going on.

              @Exception Type: EXC_BAD_ACCESS (SIGSEGV)
              Exception Codes: KERN_INVALID_ADDRESS at 0x0000000100000042

              0 QtCore 0x0000000109b7bb84 QCoreApplication::notifyInternal(QObject*, QEvent*) + 100
              1 QtGui 0x000000010a7d29a0 -[QCocoaWindow draggingEntered:] + 992
              2 QtGui 0x000000010a7d31eb -[QCocoaWindow draggingUpdated:] + 507
              3 com.apple.AppKit 0x00007fff94a00bfc sendDraggingUpdate + 128
              4 com.apple.AppKit 0x00007fff94a01d6f NSCoreDragTrackingProc + 2669
              5 com.apple.HIServices 0x00007fff90015c6d DoTrackingMessage + 357
              6 com.apple.HIServices 0x00007fff900156d2 SendTrackingMessage + 44
              7 com.apple.HIServices 0x00007fff90018aa3 DragInApplication + 264
              8 com.apple.HIServices 0x00007fff90018f0a CoreDragStartDragging + 517
              9 com.apple.AppKit 0x00007fff94a006c0 -[NSCoreDragManager _dragUntilMouseUp:accepted:] + 885
              10 com.apple.AppKit 0x00007fff949ffd8c -[NSCoreDragManager dragImage:fromWindow:at:offset:event:pasteboard:source:slideBack:] + 1455
              11 com.apple.AppKit 0x00007fff94cf8cc6 -[NSWindow(NSDrag) dragImage:at:offset:event:pasteboard:source:slideBack:] + 132
              12 QtGui 0x000000010a7cf132 QDragManager::drag(QDrag*) + 818
              13 QtGui 0x000000010a83e067 QDrag::start(QFlagsQt::DropAction) + 87
              ...@

              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