Results 1 to 8 of 8

Thread: How to catch items dropped out of scenes?

  1. #1
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default How to catch items dropped out of scenes?

    If user takes item on scene - then I "take" it out. While user drags it - item flies over application in QDrag object. When user drops it somewhere outside reasonable scene - I need return item to initial position where it was taken. But I do not see how do that. Only one thing I found - QDrag emits targetChanged() signal when drag exits outside application. But I need catch DROP event outside app. How do that?? Sure entire event processing can be implemented in app but this does not look Qt-like. Is it a huge groove in Qt D&D engine or I just missed something?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to catch items dropped out of scenes?

    If the drop doesn't work, the place where the drag starts should receive information about it as a result of QDrag::exec().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to catch items dropped out of scenes?

    Quote Originally Posted by wysota View Post
    If the drop doesn't work, the place where the drag starts should receive information about it as a result of QDrag::exec().
    And what? QDrag::exec() returns value of Qt::DropActions enum which is unusable in this case. And I call drag->exec(); in implementation of mouseMoveEvent(QGraphicsSceneMouseEvent *event) in draggable item but not in scene.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to catch items dropped out of scenes?

    Quote Originally Posted by Gourmet View Post
    And what? QDrag::exec() returns value of Qt::DropActions enum which is unusable in this case.
    Why? If Qt::IgnoreAction is returned then there was no drop.

    And I call drag->exec(); in implementation of mouseMoveEvent(QGraphicsSceneMouseEvent *event) in draggable item but not in scene.
    I don't see how that matters.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to catch items dropped out of scenes?

    Ok, this works. But looks not so... straight. I'd better prefer signal QDrag::droppedTo( QWidget*, QPointF );

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to catch items dropped out of scenes?

    That would be useless if the drop occurred outside your app. Or was canceled.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to catch items dropped out of scenes?

    Otside the app QWidget* would be 0 with QPointF representing absolute screen position. This would be enough and easy to use.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to catch items dropped out of scenes?

    Maybe in your particular case yes but I don't see what benefit it would bring to know the screen coordinates of the drop. Especially if more than one application window occupies the same screen spot. Basically it is the target application that handles the drop, the source should only know whether the semantics is to let go of the resource or not.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Multiple QGrphicsViews and scenes cause app to freeze.
    By justin123 in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2012, 00:38
  2. Trying to use single pixmap in two Scenes.
    By spawn9997 in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2009, 22:23
  3. QLayout on scenes
    By baray98 in forum Qt Programming
    Replies: 2
    Last Post: 18th November 2008, 18:22
  4. Catch drag and drop items
    By nina1983 in forum Qt Programming
    Replies: 1
    Last Post: 23rd July 2008, 18:24
  5. adding QGraphicsItem to multiple scenes
    By forrestfsu in forum Qt Programming
    Replies: 7
    Last Post: 6th November 2006, 15:25

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.