Results 1 to 2 of 2

Thread: how to get both qgraphicsscene and qgraphicsitem to both accept drops

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Location
    East Coast, USA
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question how to get both qgraphicsscene and qgraphicsitem to both accept drops

    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.

    Qt Code:
    1. MyGraphicsScene::dropEvent(....) {
    2. QGraphicsScene::dropEvent(...)
    3. if(!event->isAccepted()) {
    4. event->accept()
    5. return
    6. }
    7. else
    8. do what needs to be done if the drop is on an empty space
    9. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. MyGraphicsItem::dropEvent(...) {
    2. do things
    3. event->ignore();
    4. //This is why we did this. The event comes to us 'accept'ed. If it
    5. //passes into this function we 'ignore' it as a signal to the parent
    6. //(qgraphicsscene) that it should not operate on it. Otherwise
    7. //the event comes with the accept flag and qgraphicsscene acts in it
    8. //This is so ass-backwards. There should be
    9. //a better way of doing this
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 25th December 2008 at 14:13. Reason: changed [qtclass] to [code] tags

Similar Threads

  1. QGraphicsView, QGraphicsItem, QGraphicsScene
    By Shuchi Agrawal in forum Newbie
    Replies: 10
    Last Post: 23rd March 2011, 20:50
  2. (QT4.2-RC1) QGraphicsScene QGraphicsView QGraphicsItem
    By antonio.r.tome in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 10:56

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.