I have written an extensive review of how Qt's Drag-and-Drop architecture is used in Python and PyQt5. Here are links to the parts of the saga in proper sequence:
- Part 1, Overview
- Part 2, the Drop Target
- Part 3, the Drag Source
- Part 4, Coding a Drag Source
- Part 5, Detecting a Drop
- Part 6, Drag Moves
- Part 7, Drop the Load
- Part 8, Running Tests
- Part 9, Hacking QDrag
- Part 10, Hacking QMimeData
- Part 11, A Doh! Moment
Hi!
ReplyDeleteI have found your Qt Forums post, where you were asking when the targetChanged signal is emitted.
https://forum.qt.io/topic/36997/answered-when-is-the-signal-qdrag-targetchanged-emitted/3
Have you found the answer? Is it when cursor enters a new Drag Target, or when the Drop is allowed and performed?
Everything I learned, I put in the posts indexed from this page. In the end I did not implement the feature that I wanted. I had hoped to implement a tab bar and be able to drag a tab out of it and have it convert to an independent window -- just like with a modern browser. I could not figure out how to do that, and it was not necessary after all.
ReplyDeleteSo these posts are all I every learned. Good luck.
Ah, ok then.
ReplyDeleteMy findings regarding the targetChanged signal for anyone who wonders in here:
(a) If drag cursor dragEnterEvent()s a Widget and it acceptProposedAction()s, targetChanged(Widget) is emitted.
(b) If the Widget ignore()s dragEnterEvent, targetChanged(nullptr) is emitted and it is not emitted anymore unless (a) happens again.
What you wanted to do would be possible if you connected a function to the targetChanged signal and created an independent window (i. e. setParent(nullptr) and show()) whenever the target changed from the Tab Bar.