Results 1 to 6 of 6

Thread: QGraphicsScene doesn't accept Drops

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QGraphicsScene doesn't accept Drops

    Hi,
    I have a Class derived from QGraphicsScene. I've reimplemented its dragEnterEvent() and dropEvent() event handler. in dragEnterEvent I test for a custom mimetype and in a case of success call AcceptProposedAction(true). So far it works, but drops are still not supported. AcceptProposedAction() seems to have no effect. The cursor icon also indicated that drops are still not accepted by the QGraphicsScene. I guess the problem is that I want the Scene itself to handle the drops instead of any items on the scene. But that is exactly what I want.

    can anybody help me with this?

    thanks in advance
    momesana

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QGraphicsScene doesn't accept Drops

    Perhaps you have to reimplement dragMoveEvent() and accept the event there also.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    momesana (12th July 2007)

  4. #3
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QGraphicsScene doesn't accept Drops

    Momesana,
    Do you want to drag and drop in same widget(QGraphicsScene) or from different widget?
    what type of item you moving?

  5. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene doesn't accept Drops

    Did you enable drops in the QGraphicsView (have alook at the Drag Mode property...) ?
    Current Qt projects : QCodeEdit, RotiDeCode

  6. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QGraphicsScene doesn't accept Drops

    Thank you all for replying to my post.
    The reimplementation of dragMoveEvent did the trick .
    I was really frustated yesterday after I couldn't get it to work after 5 hours of trial and error experiments. Today I was demoralized enough to give up and try another approach. I made the QGraphicsView catch the Event.

    This also failed so I looked up the Qt Drag and Drop online documentation and searched for examples and noticed that in the examples dragMoveEvent is also implemented. I did the same and QGraphicsView could successfully catch the events. But it didn't come to my mind to apply this knowledge to GraphiscScene. I just tried it now after reading your replies and it works. Thanks jpn

  7. #6
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Thanked 38 Times in 30 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsScene doesn't accept Drops

    It's because QGraphicsScene provides a default implementation of dragMoveEvent that checks if there are items on the scene under the cursor that accept drop events. If not, the event will be ignored, and you won't be allowed to drop.
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

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.