One option would be to handle drag and drop events by installing an event filter on children.
{
DraggableLED* led = dynamic_cast<DraggableLED*>(receiver);
if (!led)
return false; // not a DraggableLED
switch (event->type())
{
// do something with led
break;
...
}
return false;
}
bool Parent::eventFilter(QObject* receiver, QEvent* event)
{
DraggableLED* led = dynamic_cast<DraggableLED*>(receiver);
if (!led)
return false; // not a DraggableLED
switch (event->type())
{
case QEvent::DragEnter:
// do something with led
break;
...
}
return false;
}
To copy to clipboard, switch view to plain text mode
The difference with reimplementing such event handler of the parent is that by the time event reaches parent it has already been ignored by the child:
void Parent::dragEnterEvent(..)
{
...
}
void Parent::dragEnterEvent(..)
{
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks