PDA

View Full Version : Drag and drop - parent notification



MrGarbage
20th September 2007, 19:59
Hi,

I have created a small LED widget which I use in
several forms. I had made theis widget draggable and had
implemented some code dragEnterEvent(), etc in the widget class to accomplish this.

This works and I am able to drag the LED to another LED.

I now realize that the LED widget does not have enough information to correctly determine
whether a certain drag and drop should be allowed. This information can only be determined
from witihin the parent form class in which the LEDs are embedded.

What I would like is to do is have functions within the parent form class called when drag
operations involving the child LED widgets occur.

How does one do this?

Thanks!

Mark

wysota
20th September 2007, 21:08
Oh... this is a terrible design... In such situation I'd really implement the drag and drop in the parent and not in the led. But if you insist on going this way, you should cast parent() to the form's class using dynamic_cast or qobject_cast and if the cast returns a non-zero pointer, you can safely call the method you want.