Dragging between separate windows in Qml
I am trying to accomplish dragging objects beetween QML windows. So far I have created my own tab view with draggable tabs (beetwen other tab views). Now I want to implement the possibility to drag tabs out to separate windows and putting windows back as tabs.
Ideally, object after being dragged from its dock should transform into a Window which I would be able to drag and release outside of the current window (creating a new one) or drop in other dock in the same window -- creates object (in my case tab).
I managed to create a new Window after dragging the tab out from the dock. Then I can dock it back in the same window without releasing the mouse, or just drop it outside (so the new window now exists separately). To achieve this I had to create my own Window derived from QQuickWindow and expose requestActivation function to Qml. You must call it when dragging out tab. Otherwise, the new window activates itself, stealing focus and events.
But after that I bumped into a few problems:
- I cannot dock the object (being dragged) in any other window than the active one. Changing the active window stops the movement of my dragged window.
- I cannot dock the Window in a dock area of another Window.
A solution to this could be to manually start the drag -- by using startDrag() at Drag attached object of the dragged object (wicked drags!). But I cannot make the Window or the object to move as mouse moves. So I managed to only implement a drag without the object following the mouse (different cursor icon is the only visual indicator of the drag process).
Eventually if dragging entire window is not possible maybe it's possible to set a pixmap for a drag (that will folow the mouse). I have seen that QDrag object (in C++ API) can have the pixmap set, however such possiblity seems to not be exposed to Qml.