Qt-interest Archive, September 2007
Getting target information from DropEvent
Message 1 in thread
Hi,
I am implementing a Drag and Drop of some LED objects.
These are embedded in some layouts which are part of a config class where
I am implementing the dragEnterEvent(), etc.
Im my LED objects' mousePressEvent() I setup QMimeData such that in my
config class dropEvent() I successfully decode the mime data that I passed
in.
So I have all of the info about the source widget...
The problem is that I need some information about the target widget in
order to determine if I will actually allow the drop and what to do
with the source mime data.
There doesn't seem to be a way to find the target widget.
I have event->pos but I don't seem to be able to get this to
map to the widget where I am dropping.
This seems like it should do it, but the result is not the target object.
DraggableLED *child = static_cast<DraggableLED*>(childAt(event->pos()));
Many thanks
Mark
--
[ signature omitted ]
Message 2 in thread
Mark Foley wrote:
> Hi,
>
> I am implementing a Drag and Drop of some LED objects.
> These are embedded in some layouts which are part of a config class where
> I am implementing the dragEnterEvent(), etc.
>
> Im my LED objects' mousePressEvent() I setup QMimeData such that in my
> config class dropEvent() I successfully decode the mime data that I
> passed
> in.
>
> So I have all of the info about the source widget...
>
> The problem is that I need some information about the target widget in
> order to determine if I will actually allow the drop and what to do
> with the source mime data.
>
> There doesn't seem to be a way to find the target widget.
> I have event->pos but I don't seem to be able to get this to
> map to the widget where I am dropping.
>
> This seems like it should do it, but the result is not the target object.
> DraggableLED *child = static_cast<DraggableLED*>(childAt(event->pos()));
I think you're searching at the wrong place. The target widget itself will
get the drag/drop events, and it is there that you can set if you will
accept or reject the drop.
André
--
[ signature omitted ]