I’m implementing a drag and drop interface with Qt across X11 and Windows. The interface handles events such that it is not illegal for a user to drop a dragged object on an area which can’t handle drops.
In this case, Qt::IgnoreAction should therefore not be treated as an incorrect potential action. To communicate this fact to the user I need a way to stop Qt::ForbiddenCursor from displaying if the current Qt::DropAction is Qt::IgnoreAction.
There are three ways I can see to achieve this (in order of preference):
- To override the
QCursorused for a drag withQt::IgnoreActionto something other thanQt::ForbiddenCursor. - To override the bitmap used for
Qt::ForbiddenCursor. This is pretty dirty but would be an acceptable solution as long as I don’t have to delve into OS-specific configuration. - To override the call made by Qt when a drag leaves a valid drop area (I assume that Qt does the equivalent of
QDropEvent::setDropAction(Qt::IgnoreAction)in this case).
Could anyone suggest ways to acheive any of the above?
Note: I have also attempted to use QApplication::setOverrideCursor() just before calling QDrag::exec(). This doesn’t seem to have any effect.
Check if
QDragEnterEventcomes to application itself (install event filter onQApplicationobject). If it does, simply accept it and cursor will appear normal.