Why call function acceptProposedAction in function dragEnterEvent?
-
Hi everyone!
Recently I learned how to implement the clipboard function. And I found Qt requires to call acceptProposedAction in the dragEnterEvent in order to trigger function dropEvent.
I find that when function acceptProposedAction isn't called in function dragEnterEvent, function dropEvent will not be called by debugging the qt source code, but I cannot find the reason.
I want to know the reason, and the corresponding qt souce code, thanks for your help!
-
Hi and welcome to devnet,
There's no reason for the system to process d&d events for a widget that is not concerned. It also allows proper feedback to the user. It's highly annoying when you drop something on a widget that does nothing rather than having an explicit icon saying the operation cannot be done.
-
Hi and welcome to devnet,
There's no reason for the system to process d&d events for a widget that is not concerned. It also allows proper feedback to the user. It's highly annoying when you drop something on a widget that does nothing rather than having an explicit icon saying the operation cannot be done.
-
@SGaist Thanks for your answer!
Do you know why the system knows that the widget concerns the d&d events after the dragEnterEvent function calls the acceptProposedAction function?
After dragEnterEvent, you have also dragMoveEvent that allows you to control more precisely where on the widget the drop can happen.
-
-
After dragEnterEvent, you have also dragMoveEvent that allows you to control more precisely where on the widget the drop can happen.
@SGaist Thanks again! I learn a lot from your answer.
Actually, at first I want to know if I can debug the souce code to find out the reason. Maybe it involves the underlying mechanism of the windows system, so that I cannot easily find out the reason by debugging the souce code.
Best regards.