[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Re: PyQt4: QGraphicsView/drag&drop problem
From:       Frank Ploss <frank.ploss () informatik ! uni-hamburg ! de>
Date:       2007-06-26 19:40:55
Message-ID: f5rq48$rc8$1 () sea ! gmane ! org
[Download RAW message or body]

Eriol wrote:

> On Thursday 21 June 2007, Frank Ploss wrote:
>> I'm trying to implement drag and drop with a QGraphicsView.
> 
> Can't you use the default Graphics View framework drag and drop support
> provided for the scene, and for each item?

No, I need better control over the look and position of dragged items.
But ...

> 
> ----8<----------------------------------
> ...
> > ------>8---------------------------------------- 
> 
> If not, consider that (from the doc:
> http://doc.trolltech.com/4.2/graphicsview.html#drag-and-drop):
> 
> To intercept drag and drop events for the scene, you reimplement
> QGraphicsScene::dragEnterEvent() and whichever event handlers your
> particular scene needs, in a QGraphicsItem subclass.

... your repeating of the docs I had already read a dozen times before
pointed me to the fact that I shouldn't catch the drop events in the
*scene* (which doesn't work), but in an *item* (which does work). So the
solution was to create a background QGraphicsRectItem, add it to the scene
and catch and process the drop events there.

Thanks!
Frank

> 
> Items can enable drag and drop support by calling
> QGraphicsItem::setAcceptDrops(). To handle the incoming drag, reimplement
> QGraphicsItem::dragEnterEvent(), QGraphicsItem::dragMoveEvent(),
> QGraphicsItem::dragLeaveEvent(), and QGraphicsItem::dropEvent().
> 
> HTH,
> 


_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic