Hi Gang,
I have some items on a qgraphicsscene and I want to be able to drag and drop an item onto another or onto a blank part of the scene. Depending on whether the drop occurs over another item or over a blank part of the scene two different things happen.
The way I'm doing this currently is backwards (I think) but is the only way I can get it to work.
MyGraphicsScene::dropEvent(....) {
if(!event->isAccepted()) {
event->accept()
return
}
else
do what needs to be done if the drop is on an empty space
}
MyGraphicsScene::dropEvent(....) {
QGraphicsScene::dropEvent(...)
if(!event->isAccepted()) {
event->accept()
return
}
else
do what needs to be done if the drop is on an empty space
}
To copy to clipboard, switch view to plain text mode
MyGraphicsItem::dropEvent(...) {
do things
event->ignore();
//This is why we did this. The event comes to us 'accept'ed. If it
//passes into this function we 'ignore' it as a signal to the parent
//(qgraphicsscene) that it should not operate on it. Otherwise
//the event comes with the accept flag and qgraphicsscene acts in it
//This is so ass-backwards. There should be
//a better way of doing this
}
MyGraphicsItem::dropEvent(...) {
do things
event->ignore();
//This is why we did this. The event comes to us 'accept'ed. If it
//passes into this function we 'ignore' it as a signal to the parent
//(qgraphicsscene) that it should not operate on it. Otherwise
//the event comes with the accept flag and qgraphicsscene acts in it
//This is so ass-backwards. There should be
//a better way of doing this
}
To copy to clipboard, switch view to plain text mode
Bookmarks