Drag and Drop With Overlaying QWidget
-
Hi,
Did you tried with an event filter ?
-
Hi SGalst, and thank you for your reply!
No, I didn't. What would you suggest? Seeing if ignoring the drag related events would give me the wanted result?
-
I was rather thinking about intercepting the events and sending them to the right widget (using postEvent)
-
Ah postEvent, thanks that will be useful.
-
I may require some more guidance here - still stuck.
Here's what I did: I allowed the overlaying label to accept the drag events, but from the main application window, I used eventFilter to catch the drop event. I then tried to generate the QDragEnterEvent / QDragMoveEvent / QDropEvent objects myself in the eventFilter function and to use sendEvent().
Though the sendEvent() call returns true, my check for isAccepted() tells me the event was not accepted.
Any more help please?
-
Why not use the events you are receiving ?
-
What do you mean, use them? I wanted to pass them on to the QTableView so that it handles them (eventually that would be activating the mime data drop functionality). But I couldn't get the sendEvent() to work, or so it seems.
What I eventually did as a workaround: I filtered just the drop event and then used its mimedata to manually drop mime data onto the table view.
-
I understood that you where creating new events based on those you received rather than sending them to the table view.
Your workaround doesn't seem bad
-
I tried sending the original events and I would get crashes. I then tried creating new events and that just wouldn't work. Then workaround. :)
-
Sounds reasonable for me :)
You could to try asking on the mailing if there is another possibility for this (you might cross the path of a maintainer/developer with some other ideas on the matter)