PDA

View Full Version : drag/dropping outside app



musikit
29th February 2008, 13:06
hello,

i have a custom widget i am trying to implement drag/drop on. what i want to happen is when the user drags my custom widget outside of the application i want to create a new window for that widget.

i am having some difficultly though as i understand how to accept drag/drop operations inside the widget (been using this for awhile within other custom widgets).

i tried overloading dragleaveevent however i didnt get the outcome id expect.

has anyone tried this before? and possibly point me in the correct direction?

wysota
29th February 2008, 14:02
i have a custom widget i am trying to implement drag/drop on. what i want to happen is when the user drags my custom widget outside of the application i want to create a new window for that widget.

From what I understand, what you are trying to do is very hard to achieve. The reason is that the drop is handled not by the application where the drag originates but by the application where the object is dropped - in your case the desktop. There probably is some platform dependent API that is able to perform what you want, but currently Qt won't handle such cases just by itself. You could register a quasi application handling some mime-type in your system and then this application could do "something" to spawn that window, but in my opinion this is a very complex task.

musikit
29th February 2008, 15:33
ok... well while building other portions of my custom widget's drag/drop i did notice that if i drag/drop it over the desktop i get an "IgnoreAction"

could i just overload the "IgnoreAction" to do what i want? or is that not recommended?

wysota
29th February 2008, 15:40
Overload where? As I said, your application will not be called when a drop on the desktop occurs. You won't know where the object was dropped on and if it was dropped at all (ignore action can occur both when a drag has been canceled or when the drop occured on an invalid target).

aamer4yu
29th February 2008, 17:34
I am not sure... but may be you can try this...

Find the id of desktop.
In drag action, check the target. If it equals the desktop, then launch a widget as u desire.

Hope it helps.