[Solved] Using a custom mouse-cursor for QDrag
-
This might be a difficult problem. I want to do a drag&drop operation that uses a custom cursor (not a sub-cursor but the "real" one). QDrag::setDragCursor only takes care of the sub-cursor and even QGuiApplication::setOverrideCursor does not help in changing the mouse cursor during a drag&drop operation. I always get a black arrow (might depend on the style of the application or the operating system).
If I am just horribly stupid and missing an easy solution, please help me out. Otherwise I would appreciate any kind of idea of where this unchangeable cursor might come from. Maybe it can be changed by modifying Qt somehow.
EDIT
I gave up on QDrag and implemented a custom Drag&Drop - now one can drag around widgets directly instead of having to use QDrag and "faking" a moving widget by using a static pixmap. This speeds things up, allows for new possibilities, shortens the code but does not allow for communicating between different processes. ( "here":http://qt-project.org/forums/viewthread/46950/ is a bit more to read about it) -
Well something you could do is set the mouse cursor for the widget you are dragging in with QCursor.
I don't know by your question if you want to change the cursor system wide or just in a certain widget.
If it's widget only you can change the widget's cursor on a drag start event and change it back on a drag end event.
-
Setting the QCursor for a widget doesn't help, QDrag brings along its own cursor. Since it is dragging a pixmap and not the widget itself, the mouse wouldn't stay over the widget during the operation anyway.
And even when I override the applications cursor (!), QDrag decides to use its own.
I think I need to find a way to circumvent using QDrag altogether, it probably could use a complete rewrite.