Mouse manager for the Qt4 graphics framework.

Mouse management for the Qt4 graphics framework is implemented by a set of MouseMode objects, that provide specific event handlers and behave like a descriptor, and a manager object that catches mouse events and dispatch them to the appropriate hendler.

The MouseManager provides methods for eddeing/removing mouse modes, making the system expandible, and also methods to register objects (QGraphicsScene and QGraphicsView) to be controlled.


MouseManager([parent, stdmodes])
MouseMode Base class for mouse mode desctiptors.
RubberBandMode Mouse mode for rubber band selection.
class gsdview.mousemanager.MouseManager(parent=None, stdmodes=True, **kwargs)[source]

Bases: PyQt4.QtCore.QObject

eventFilter(obj, event)[source]

Events dispatcher


Return the mouse mode object


mouse mode name


SIGNAL: it is emitted when the mouse mode is changed

C++ signature:void modeChanged(const QString&)

Register a Qt graphics object to be monitored by the mouse manager.

QGraphicsScene and QGrapgicsViews (and descending classes) objects can be registered to be monitored by the mouse manager.

Scene objects associated to views (passes as argument) are automatically registered.


Unregister monitored objects.

If the object passed as argument is not a registered object nothing happens.


this method never tries to unregister scene objects associated to the view passed as argument.

class gsdview.mousemanager.MouseMode[source]

Bases: PyQt4.QtCore.QObject

Base class for mouse mode desctiptors.

Qt Graphics Framework mouse mode descriptors define some basic property for mouse related matters:

  • cursor
  • dragmode
  • eventFilter
  • name
  • label
  • icon

The first three properties (not to be intender as python progremming language property) are strongly characterizing of the way the mouse works.

In particular the eventFilter method is used to filter all events coming from graphics scenes an graphics views.


in order to work properly the eventFilter should be installed on both graphics scene and view and also on the scrollbars of the graphics view. So please always use the register method of MouseManager for a proper installaton of al event filters.

cursor = None
dragmode = 0
eventFilter(obj, event)[source]

Basic implementation of the eventFilter method.

The dafault implementation makes some basic operation such setting the mouse cursor anc dispatch the event to specific methods:

  • sceneEventFilter
  • viewEventFilter
  • scrollbarEventFilter

In most of the cases derived classes only need to specialize one or more of this specific methods.

icon = <PyQt4.QtGui.QIcon object at 0x48444d0>
label = ''
name = ''
sceneEventFilter(obj, event)[source]
scrollbarEventFilter(obj, event)[source]
viewEventFilter(obj, event)[source]
class gsdview.mousemanager.PointerMode[source]

Bases: gsdview.mousemanager.MouseMode

cursor = None
dragmode = 0
icon = <PyQt4.QtGui.QIcon object at 0x4844560>
label = 'Pointer'
name = 'pointer'
class gsdview.mousemanager.RubberBandMode[source]

Bases: gsdview.mousemanager.MouseMode

Mouse mode for rubber band selection.

Signals :
cursor = 2
dragmode = 2
icon = <PyQt4.QtGui.QIcon object at 0x4844680>
label = 'Rubber band'
name = 'rubberband'

SIGNAL: it is emitted when a rectangular area is selected

C++ signature:void rubberBandSeclection(const QRectF&)
sceneEventFilter(obj, event)[source]
scrollbarEventFilter(obj, event)[source]
class gsdview.mousemanager.ScrollHandMode[source]

Bases: gsdview.mousemanager.MouseMode

cursor = None
dragmode = 1
icon = <PyQt4.QtGui.QIcon object at 0x48445f0>
label = 'Scroll hand'
name = 'hand'
scrollbarEventFilter(obj, event)[source]
viewEventFilter(obj, event)[source]

Get GSDView at Fast, secure and Free Open Source software downloads

Previous topic


Next topic


This Page