[PyQt] QGraphicsView rubberband selection
antonio.valentino at tiscali.it
Fri Oct 30 08:44:51 GMT 2009
Il giorno Thu, 29 Oct 2009 16:53:04 +0100
Alexander Borghgraef <alexander.borghgraef.rma at gmail.com> ha scritto:
> Hi all,
> I've been writing an app which displays sequences of images, and
> allows for the selection of regions of interest in them.
> Display/playback works like a charm, basically I use a
> QGraphicsScene/View setup with a QGraphicsPixmapItem in the scene,
> which is then updated upon receiving the timeout signal of a timer.
> Pretty basic stuff.
> Now for selection: one approach would be to subclass either the
> QGraphicsView or the QGraphicsPixmapItem, overload the mouse
> events, get the selection coordinates from that for further use and
> put a QGraphicsRectItem on the scene on top of the selection.
Yes, one solution is subclassing, another could be using
> Now, I noticed that QGraphicsView already has rubberband selection
> implemented: when I set the View's DragMode to
> QGraphicsView.RubberBandDrag, I get a nice rubberband rectangle when
> I drag the mouse across the View. My problem here is
> that I can't seem to figure out how to access the selection
> coordinates of that rectangle. Is there some way of accessing this
> data? There doesn't seem to be any getDragSelection( ) or some such
> function, but then how does this work? Do I need to get it from the
> underlying QGraphicsScene object? Help would be appreciated.
I have the same problem. At the moment I have a solution based on
event filters but I'm very interested in a solution exploiting built-in
features so please keep updated.
More information about the PyQt