Qt 4.8
|
The QGraphicsSceneEvent class provides a base class for all graphics view related events. More...
#include <qgraphicssceneevent.h>
Public Functions | |
QGraphicsSceneEvent (Type type) | |
Constructs a generic graphics scene event of the specified type. More... | |
void | setWidget (QWidget *widget) |
Sets the widget related to this event. More... | |
QWidget * | widget () const |
Returns the widget where the event originated, or 0 if the event originates from another application. More... | |
~QGraphicsSceneEvent () | |
Destroys the event. More... | |
Public Functions inherited from QEvent | |
void | accept () |
Sets the accept flag of the event object, the equivalent of calling setAccepted(true). More... | |
void | ignore () |
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false). More... | |
bool | isAccepted () const |
QEvent (Type type) | |
Contructs an event object of type type. More... | |
void | setAccepted (bool accepted) |
bool | spontaneous () const |
Returns true if the event originated outside the application (a system event); otherwise returns false. More... | |
Type | type () const |
Returns the event type. More... | |
virtual | ~QEvent () |
Destroys the event. More... | |
Protected Functions | |
QGraphicsSceneEvent (QGraphicsSceneEventPrivate &dd, Type type=None) | |
Constructs a generic graphics scene event. More... | |
Protected Variables | |
QScopedPointer< QGraphicsSceneEventPrivate > | d_ptr |
Protected Variables inherited from QEvent | |
QEventPrivate * | d |
ushort | t |
The QGraphicsSceneEvent class provides a base class for all graphics view related events.
When a QGraphicsView receives Qt mouse, keyboard, and drag and drop events (QMouseEvent, QKeyEvent, QDragEvent, etc.), it translates them into instances of QGraphicsSceneEvent subclasses and forwards them to the QGraphicsScene it displays. The scene then forwards the events to the relevant items.
For example, when a QGraphicsView receives a QMouseEvent of type MousePress as a response to a user click, the view sends a QGraphicsSceneMouseEvent of type GraphicsSceneMousePress to the underlying QGraphicsScene through its QGraphicsScene::mousePressEvent() function. The default QGraphicsScene::mousePressEvent() implementation determines which item was clicked and forwards the event to QGraphicsItem::mousePressEvent().
Subclasses such as QGraphicsSceneMouseEvent and QGraphicsSceneContextMenuEvent provide the coordinates from the original QEvent in screen, scene, and item coordinates (see QGraphicsSceneMouseEvent::screenPos(), QGraphicsSceneMouseEvent::scenePos(), and QGraphicsSceneMouseEvent::pos()). The item coordinates are set by the QGraphicsScene before it forwards the event to the event to a QGraphicsItem. The mouse events also add the possibility to retrieve the coordinates from the last event received by the view (see QGraphicsSceneMouseEvent::lastScreenPos(), QGraphicsSceneMouseEvent::lastScenePos(), and QGraphicsSceneMouseEvent::lastPos()).
Definition at line 67 of file qgraphicssceneevent.h.
QGraphicsSceneEvent::QGraphicsSceneEvent | ( | Type | type | ) |
Constructs a generic graphics scene event of the specified type.
Definition at line 324 of file qgraphicssceneevent.cpp.
QGraphicsSceneEvent::~QGraphicsSceneEvent | ( | ) |
|
protected |
Constructs a generic graphics scene event.
Definition at line 338 of file qgraphicssceneevent.cpp.
void QGraphicsSceneEvent::setWidget | ( | QWidget * | widget | ) |
Sets the widget related to this event.
Definition at line 370 of file qgraphicssceneevent.cpp.
Referenced by _q_hoverFromMouseEvent(), QGraphicsScenePrivate::cloneDragDropEvent(), cloneEvent(), QGraphicsView::contextMenuEvent(), QGraphicsView::dragLeaveEvent(), QGraphicsScenePrivate::leaveScene(), QGraphicsView::mouseDoubleClickEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsView::mousePressEvent(), QGraphicsView::mouseReleaseEvent(), QGraphicsViewPrivate::populateSceneDragDropEvent(), QGraphicsViewPrivate::storeDragDropEvent(), QGraphicsView::viewportEvent(), and QGraphicsView::wheelEvent().
QWidget * QGraphicsSceneEvent::widget | ( | ) | const |
Returns the widget where the event originated, or 0 if the event originates from another application.
Definition at line 355 of file qgraphicssceneevent.cpp.
Referenced by _q_hoverFromMouseEvent(), QGraphicsScenePrivate::cloneDragDropEvent(), cloneEvent(), QGraphicsScene::contextMenuEvent(), QGraphicsScenePrivate::dispatchHoverEvent(), QGraphicsScene::helpEvent(), QGraphicsItem::mouseMoveEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QGraphicsScenePrivate::mousePressEventHandler(), QTextControl::processEvent(), QGraphicsScenePrivate::sendDragDropEvent(), QGraphicsScenePrivate::sendHoverEvent(), QGraphicsScenePrivate::sendMouseEvent(), setWidget(), QGraphicsViewPrivate::storeDragDropEvent(), QGraphicsScene::wheelEvent(), and QGraphicsWidgetPrivate::windowFrameMouseReleaseEvent().
|
protected |
Definition at line 78 of file qgraphicssceneevent.h.
Referenced by QGraphicsSceneEvent(), setWidget(), and widget().