1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtGui module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
43
\class QGraphicsSceneEvent
44
\brief The QGraphicsSceneEvent class provides a base class for all
45
graphics view related events.
47
\ingroup graphicsview-api
50
When a QGraphicsView receives Qt mouse, keyboard, and drag and
51
drop events (QMouseEvent, QKeyEvent, QDragEvent, etc.), it
52
translates them into instances of QGraphicsSceneEvent subclasses
53
and forwards them to the QGraphicsScene it displays. The scene
54
then forwards the events to the relevant items.
56
For example, when a QGraphicsView receives a QMouseEvent of type
57
MousePress as a response to a user click, the view sends a
58
QGraphicsSceneMouseEvent of type GraphicsSceneMousePress to the
59
underlying QGraphicsScene through its
60
\l{QGraphicsScene::}{mousePressEvent()} function. The default
61
QGraphicsScene::mousePressEvent() implementation determines which
62
item was clicked and forwards the event to
63
QGraphicsItem::mousePressEvent().
65
\omit ### Beskrive widget() \endomit
67
Subclasses such as QGraphicsSceneMouseEvent and
68
QGraphicsSceneContextMenuEvent provide the coordinates from the
69
original QEvent in screen, scene, and item coordinates (see
70
\l{QGraphicsSceneMouseEvent::}{screenPos()},
71
\l{QGraphicsSceneMouseEvent::}{scenePos()}, and
72
\l{QGraphicsSceneMouseEvent::}{pos()}). The item coordinates are
73
set by the QGraphicsScene before it forwards the event to the
74
event to a QGraphicsItem. The mouse events also add the
75
possibility to retrieve the coordinates from the last event
76
received by the view (see
77
\l{QGraphicsSceneMouseEvent::}{lastScreenPos()},
78
\l{QGraphicsSceneMouseEvent::}{lastScenePos()}, and
79
\l{QGraphicsSceneMouseEvent::}{lastPos()}).
85
\class QGraphicsSceneMouseEvent
86
\brief The QGraphicsSceneMouseEvent class provides mouse events
87
in the graphics view framework.
89
\ingroup graphicsview-api
92
When a QGraphicsView receives a QMouseEvent, it translates it to a
93
QGraphicsSceneMouseEvent. The event is then forwarded to the
94
QGraphicsScene associated with the view. If the event is not
95
handled by the scene, the view may use it, e.g., for the
96
\l{QGraphicsView::}{DragMode}.
98
In addition to containing the item, scene, and screen coordinates
99
of the event (as pos(), scenePos(), and screenPos()), mouse
100
events also contain the coordinates of the previous mouse
101
event received by the view. These can be retrieved with
102
lastPos(), lastScreenPos(), and lastScenePos().
104
\sa QGraphicsSceneContextMenuEvent,
105
QGraphicsSceneHoverEvent, QGraphicsSceneWheelEvent,
110
\class QGraphicsSceneWheelEvent
111
\brief The QGraphicsSceneWheelEvent class provides wheel events
112
in the graphics view framework.
113
\brief The QGraphicsSceneWheelEvent class provides wheel events in the
114
graphics view framework.
116
\ingroup graphicsview-api
119
\l{QWheelEvent}{QWheelEvent}s received by a QGraphicsView are translated
120
into QGraphicsSceneWheelEvents; it translates the QWheelEvent::globalPos()
121
into item, scene, and screen coordinates (pos(), scenePos(), and
124
\sa QGraphicsSceneMouseEvent, QGraphicsSceneContextMenuEvent,
125
QGraphicsSceneHoverEvent, QWheelEvent
129
\class QGraphicsSceneContextMenuEvent
130
\brief The QGraphicsSceneContextMenuEvent class provides context
131
menu events in the graphics view framework.
133
\ingroup graphicsview-api
136
A QContextMenuEvent received by a QGraphicsView is translated
137
into a QGraphicsSceneContextMenuEvent. The
138
QContextMenuEvent::globalPos() is translated into item, scene, and
139
screen coordinates (pos(), scenePos(), and screenPos()).
141
\sa QGraphicsSceneMouseEvent, QGraphicsSceneWheelEvent,
146
\enum QGraphicsSceneContextMenuEvent::Reason
148
This enum describes the reason why the context event was sent.
150
\value Mouse The mouse caused the event to be sent. On most
151
platforms, this means the right mouse button was clicked.
153
\value Keyboard The keyboard caused this event to be sent. On
154
Windows and Mac OS X, this means the menu button was pressed.
156
\value Other The event was sent by some other means (i.e. not
157
by the mouse or keyboard).
161
\class QGraphicsSceneHoverEvent
162
\brief The QGraphicsSceneHoverEvent class provides hover events
163
in the graphics view framework.
165
\ingroup graphicsview-api
168
When a QGraphicsView receives a QHoverEvent event, it translates
169
it into QGraphicsSceneHoverEvent. The event is then forwarded to
170
the QGraphicsScene associated with the view.
172
\sa QGraphicsSceneMouseEvent, QGraphicsSceneContextMenuEvent,
173
QGraphicsSceneWheelEvent, QHoverEvent
177
\class QGraphicsSceneHelpEvent
178
\brief The QGraphicsSceneHelpEvent class provides events when a
179
tooltip is requested.
181
\ingroup graphicsview-api
184
When a QGraphicsView receives a QEvent of type
185
QEvent::ToolTip, it creates a QGraphicsSceneHelpEvent, which is
186
forwarded to the scene. You can set a tooltip on a QGraphicsItem
187
with \l{QGraphicsItem::}{setToolTip()}; by default QGraphicsScene
188
displays the tooltip of the QGraphicsItem with the highest
189
z-value (i.e, the top-most item) under the mouse position.
191
QGraphicsView does not forward events when
192
\l{QWhatsThis}{"What's This"} and \l{QStatusTipEvent}{status tip}
193
help is requested. If you need this, you can reimplement
194
QGraphicsView::viewportEvent() and forward QStatusTipEvent
195
events and \l{QEvent}{QEvents} of type QEvent::WhatsThis to the
202
\class QGraphicsSceneDragDropEvent
203
\brief The QGraphicsSceneDragDropEvent class provides events for
204
drag and drop in the graphics view framework.
206
\ingroup graphicsview-api
209
QGraphicsView inherits the drag and drop functionality provided
210
by QWidget. When it receives a drag and drop event, it translates
211
it to a QGraphicsSceneDragDropEvent.
213
QGraphicsSceneDragDropEvent stores events of type
214
GraphicsSceneDragEnter, GraphicsSceneDragLeave,
215
GraphicsSceneDragMove, or GraphicsSceneDrop.
217
QGraphicsSceneDragDropEvent contains the position of the mouse
218
cursor in both item, scene, and screen coordinates; this can be
219
retrieved with pos(), scenePos(), and screenPos().
221
The scene sends the event to the first QGraphicsItem under the
222
mouse cursor that accepts drops; a graphics item is set to accept
223
drops with \l{QGraphicsItem::}{setAcceptDrops()}.
227
\class QGraphicsSceneResizeEvent
228
\brief The QGraphicsSceneResizeEvent class provides events for widget
229
resizing in the graphics view framework.
231
\ingroup graphicsview-api
234
A QGraphicsWidget sends itself a QGraphicsSceneResizeEvent immediately
235
when its geometry changes.
237
It's similar to QResizeEvent, but its sizes, oldSize() and newSize(), use
238
QSizeF instead of QSize.
240
\sa QGraphicsWidget::setGeometry(), QGraphicsWidget::resize()
244
\class QGraphicsSceneMoveEvent
245
\brief The QGraphicsSceneMoveEvent class provides events for widget
246
moving in the graphics view framework.
248
\ingroup graphicsview-api
251
A QGraphicsWidget sends itself a QGraphicsSceneMoveEvent immediately when
252
its local position changes. The delivery is implemented as part of
253
QGraphicsItem::itemChange().
255
It's similar to QMoveEvent, but its positions, oldPos() and newPos(), use
256
QPointF instead of QPoint.
258
\sa QGraphicsItem::setPos(), QGraphicsItem::ItemPositionChange,
259
QGraphicsItem::ItemPositionHasChanged
262
#include "qgraphicssceneevent.h"
264
#ifndef QT_NO_GRAPHICSVIEW
267
#include <QtCore/qdebug.h>
269
#include <QtCore/qmap.h>
270
#include <QtCore/qpoint.h>
271
#include <QtCore/qsize.h>
272
#include <QtCore/qstring.h>
273
#include "qgraphicsview.h"
274
#include "qgraphicsitem.h"
275
#include <QtWidgets/qgesture.h>
276
#include <private/qevent_p.h>
280
class QGraphicsSceneEventPrivate
283
inline QGraphicsSceneEventPrivate()
288
inline virtual ~QGraphicsSceneEventPrivate()
292
QGraphicsSceneEvent *q_ptr;
298
Constructs a generic graphics scene event of the specified \a type.
300
QGraphicsSceneEvent::QGraphicsSceneEvent(Type type)
301
: QEvent(type), d_ptr(new QGraphicsSceneEventPrivate)
309
Constructs a generic graphics scene event.
311
QGraphicsSceneEvent::QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type)
312
: QEvent(type), d_ptr(&dd)
320
QGraphicsSceneEvent::~QGraphicsSceneEvent()
325
Returns the widget where the event originated, or 0 if the event
326
originates from another application.
328
QWidget *QGraphicsSceneEvent::widget() const
330
return d_ptr->widget;
336
Sets the \a widget related to this event.
340
void QGraphicsSceneEvent::setWidget(QWidget *widget)
342
d_ptr->widget = widget;
345
class QGraphicsSceneMouseEventPrivate : public QGraphicsSceneEventPrivate
347
Q_DECLARE_PUBLIC(QGraphicsSceneMouseEvent)
349
inline QGraphicsSceneMouseEventPrivate()
350
: button(Qt::NoButton),
351
buttons(0), modifiers(0)
358
QPointF lastScenePos;
359
QPoint lastScreenPos;
360
QMap<Qt::MouseButton, QPointF> buttonDownPos;
361
QMap<Qt::MouseButton, QPointF> buttonDownScenePos;
362
QMap<Qt::MouseButton, QPoint> buttonDownScreenPos;
363
Qt::MouseButton button;
364
Qt::MouseButtons buttons;
365
Qt::KeyboardModifiers modifiers;
371
Constructs a generic graphics scene mouse event of the specified \a type.
373
QGraphicsSceneMouseEvent::QGraphicsSceneMouseEvent(Type type)
374
: QGraphicsSceneEvent(*new QGraphicsSceneMouseEventPrivate, type)
381
QGraphicsSceneMouseEvent::~QGraphicsSceneMouseEvent()
386
Returns the mouse cursor position in item coordinates.
388
\sa scenePos(), screenPos(), lastPos()
390
QPointF QGraphicsSceneMouseEvent::pos() const
392
Q_D(const QGraphicsSceneMouseEvent);
399
void QGraphicsSceneMouseEvent::setPos(const QPointF &pos)
401
Q_D(QGraphicsSceneMouseEvent);
406
Returns the mouse cursor position in scene coordinates.
408
\sa pos(), screenPos(), lastScenePos()
410
QPointF QGraphicsSceneMouseEvent::scenePos() const
412
Q_D(const QGraphicsSceneMouseEvent);
419
void QGraphicsSceneMouseEvent::setScenePos(const QPointF &pos)
421
Q_D(QGraphicsSceneMouseEvent);
426
Returns the mouse cursor position in screen coordinates.
428
\sa pos(), scenePos(), lastScreenPos()
430
QPoint QGraphicsSceneMouseEvent::screenPos() const
432
Q_D(const QGraphicsSceneMouseEvent);
439
void QGraphicsSceneMouseEvent::setScreenPos(const QPoint &pos)
441
Q_D(QGraphicsSceneMouseEvent);
446
Returns the mouse cursor position in item coordinates where the specified
447
\a button was clicked.
449
\sa buttonDownScenePos(), buttonDownScreenPos(), pos()
451
QPointF QGraphicsSceneMouseEvent::buttonDownPos(Qt::MouseButton button) const
453
Q_D(const QGraphicsSceneMouseEvent);
454
return d->buttonDownPos.value(button);
460
void QGraphicsSceneMouseEvent::setButtonDownPos(Qt::MouseButton button, const QPointF &pos)
462
Q_D(QGraphicsSceneMouseEvent);
463
d->buttonDownPos.insert(button, pos);
467
Returns the mouse cursor position in scene coordinates where the
468
specified \a button was clicked.
470
\sa buttonDownPos(), buttonDownScreenPos(), scenePos()
472
QPointF QGraphicsSceneMouseEvent::buttonDownScenePos(Qt::MouseButton button) const
474
Q_D(const QGraphicsSceneMouseEvent);
475
return d->buttonDownScenePos.value(button);
481
void QGraphicsSceneMouseEvent::setButtonDownScenePos(Qt::MouseButton button, const QPointF &pos)
483
Q_D(QGraphicsSceneMouseEvent);
484
d->buttonDownScenePos.insert(button, pos);
488
Returns the mouse cursor position in screen coordinates where the
489
specified \a button was clicked.
491
\sa screenPos(), buttonDownPos(), buttonDownScenePos()
493
QPoint QGraphicsSceneMouseEvent::buttonDownScreenPos(Qt::MouseButton button) const
495
Q_D(const QGraphicsSceneMouseEvent);
496
return d->buttonDownScreenPos.value(button);
502
void QGraphicsSceneMouseEvent::setButtonDownScreenPos(Qt::MouseButton button, const QPoint &pos)
504
Q_D(QGraphicsSceneMouseEvent);
505
d->buttonDownScreenPos.insert(button, pos);
509
Returns the last recorded mouse cursor position in item
512
\sa lastScenePos(), lastScreenPos(), pos()
514
QPointF QGraphicsSceneMouseEvent::lastPos() const
516
Q_D(const QGraphicsSceneMouseEvent);
523
void QGraphicsSceneMouseEvent::setLastPos(const QPointF &pos)
525
Q_D(QGraphicsSceneMouseEvent);
530
Returns the last recorded mouse cursor position in scene
531
coordinates. The last recorded position is the position of
532
the previous mouse event received by the view that created
535
\sa lastPos(), lastScreenPos(), scenePos()
537
QPointF QGraphicsSceneMouseEvent::lastScenePos() const
539
Q_D(const QGraphicsSceneMouseEvent);
540
return d->lastScenePos;
546
void QGraphicsSceneMouseEvent::setLastScenePos(const QPointF &pos)
548
Q_D(QGraphicsSceneMouseEvent);
549
d->lastScenePos = pos;
553
Returns the last recorded mouse cursor position in screen
554
coordinates. The last recorded position is the position of
555
the previous mouse event received by the view that created
558
\sa lastPos(), lastScenePos(), screenPos()
560
QPoint QGraphicsSceneMouseEvent::lastScreenPos() const
562
Q_D(const QGraphicsSceneMouseEvent);
563
return d->lastScreenPos;
569
void QGraphicsSceneMouseEvent::setLastScreenPos(const QPoint &pos)
571
Q_D(QGraphicsSceneMouseEvent);
572
d->lastScreenPos = pos;
576
Returns the combination of mouse buttons that were pressed at the
577
time the event was sent.
579
\sa button(), modifiers()
581
Qt::MouseButtons QGraphicsSceneMouseEvent::buttons() const
583
Q_D(const QGraphicsSceneMouseEvent);
590
void QGraphicsSceneMouseEvent::setButtons(Qt::MouseButtons buttons)
592
Q_D(QGraphicsSceneMouseEvent);
593
d->buttons = buttons;
597
Returns the mouse button (if any) that caused the event.
599
\sa buttons(), modifiers()
601
Qt::MouseButton QGraphicsSceneMouseEvent::button() const
603
Q_D(const QGraphicsSceneMouseEvent);
610
void QGraphicsSceneMouseEvent::setButton(Qt::MouseButton button)
612
Q_D(QGraphicsSceneMouseEvent);
617
Returns the keyboard modifiers in use at the time the event was
620
\sa buttons(), button()
622
Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers() const
624
Q_D(const QGraphicsSceneMouseEvent);
631
void QGraphicsSceneMouseEvent::setModifiers(Qt::KeyboardModifiers modifiers)
633
Q_D(QGraphicsSceneMouseEvent);
634
d->modifiers = modifiers;
637
class QGraphicsSceneWheelEventPrivate : public QGraphicsSceneEventPrivate
639
Q_DECLARE_PUBLIC(QGraphicsSceneWheelEvent)
641
inline QGraphicsSceneWheelEventPrivate()
642
: buttons(0), modifiers(0), delta(0), orientation(Qt::Horizontal)
648
Qt::MouseButtons buttons;
649
Qt::KeyboardModifiers modifiers;
651
Qt::Orientation orientation;
657
Constructs a QGraphicsSceneWheelEvent of type \a type, which
658
is always QEvent::GraphicsSceneWheel.
660
QGraphicsSceneWheelEvent::QGraphicsSceneWheelEvent(Type type)
661
: QGraphicsSceneEvent(*new QGraphicsSceneWheelEventPrivate, type)
666
Destroys the QGraphicsSceneWheelEvent.
668
QGraphicsSceneWheelEvent::~QGraphicsSceneWheelEvent()
673
Returns the position of the cursor in item coordinates when the
674
wheel event occurred.
676
\sa scenePos(), screenPos()
678
QPointF QGraphicsSceneWheelEvent::pos() const
680
Q_D(const QGraphicsSceneWheelEvent);
687
void QGraphicsSceneWheelEvent::setPos(const QPointF &pos)
689
Q_D(QGraphicsSceneWheelEvent);
694
Returns the position of the cursor in scene coordinates when the wheel
697
\sa pos(), screenPos()
699
QPointF QGraphicsSceneWheelEvent::scenePos() const
701
Q_D(const QGraphicsSceneWheelEvent);
708
void QGraphicsSceneWheelEvent::setScenePos(const QPointF &pos)
710
Q_D(QGraphicsSceneWheelEvent);
715
Returns the position of the cursor in screen coordinates when the wheel
718
\sa pos(), scenePos()
720
QPoint QGraphicsSceneWheelEvent::screenPos() const
722
Q_D(const QGraphicsSceneWheelEvent);
729
void QGraphicsSceneWheelEvent::setScreenPos(const QPoint &pos)
731
Q_D(QGraphicsSceneWheelEvent);
736
Returns the mouse buttons that were pressed when the wheel event occurred.
740
Qt::MouseButtons QGraphicsSceneWheelEvent::buttons() const
742
Q_D(const QGraphicsSceneWheelEvent);
749
void QGraphicsSceneWheelEvent::setButtons(Qt::MouseButtons buttons)
751
Q_D(QGraphicsSceneWheelEvent);
752
d->buttons = buttons;
756
Returns the keyboard modifiers that were active when the wheel event
761
Qt::KeyboardModifiers QGraphicsSceneWheelEvent::modifiers() const
763
Q_D(const QGraphicsSceneWheelEvent);
770
void QGraphicsSceneWheelEvent::setModifiers(Qt::KeyboardModifiers modifiers)
772
Q_D(QGraphicsSceneWheelEvent);
773
d->modifiers = modifiers;
777
Returns the distance that the wheel is rotated, in eighths (1/8s)
778
of a degree. A positive value indicates that the wheel was
779
rotated forwards away from the user; a negative value indicates
780
that the wheel was rotated backwards toward the user.
782
Most mouse types work in steps of 15 degrees, in which case the delta
783
value is a multiple of 120 (== 15 * 8).
785
int QGraphicsSceneWheelEvent::delta() const
787
Q_D(const QGraphicsSceneWheelEvent);
794
void QGraphicsSceneWheelEvent::setDelta(int delta)
796
Q_D(QGraphicsSceneWheelEvent);
801
Returns the wheel orientation.
803
Qt::Orientation QGraphicsSceneWheelEvent::orientation() const
805
Q_D(const QGraphicsSceneWheelEvent);
806
return d->orientation;
812
void QGraphicsSceneWheelEvent::setOrientation(Qt::Orientation orientation)
814
Q_D(QGraphicsSceneWheelEvent);
815
d->orientation = orientation;
818
class QGraphicsSceneContextMenuEventPrivate : public QGraphicsSceneEventPrivate
820
Q_DECLARE_PUBLIC(QGraphicsSceneContextMenuEvent)
822
inline QGraphicsSceneContextMenuEventPrivate()
823
: modifiers(0), reason(QGraphicsSceneContextMenuEvent::Other)
829
Qt::KeyboardModifiers modifiers;
830
QGraphicsSceneContextMenuEvent::Reason reason;
836
Constructs a graphics scene context menu event of the specified \a type.
838
QGraphicsSceneContextMenuEvent::QGraphicsSceneContextMenuEvent(Type type)
839
: QGraphicsSceneEvent(*new QGraphicsSceneContextMenuEventPrivate, type)
846
QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent()
851
Returns the position of the mouse cursor in item coordinates at the moment
852
the context menu was requested.
854
\sa scenePos(), screenPos()
856
QPointF QGraphicsSceneContextMenuEvent::pos() const
858
Q_D(const QGraphicsSceneContextMenuEvent);
863
\fn void QGraphicsSceneContextMenuEvent::setPos(const QPointF &point)
866
Sets the position associated with the context menu to the given \a point
869
void QGraphicsSceneContextMenuEvent::setPos(const QPointF &pos)
871
Q_D(QGraphicsSceneContextMenuEvent);
876
Returns the position of the mouse cursor in scene coordinates at the moment the
877
the context menu was requested.
879
\sa pos(), screenPos()
881
QPointF QGraphicsSceneContextMenuEvent::scenePos() const
883
Q_D(const QGraphicsSceneContextMenuEvent);
888
\fn void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &point)
891
Sets the position associated with the context menu to the given \a point
892
in scene coordinates.
894
void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &pos)
896
Q_D(QGraphicsSceneContextMenuEvent);
901
Returns the position of the mouse cursor in screen coordinates at the moment the
902
the context menu was requested.
904
\sa pos(), scenePos()
906
QPoint QGraphicsSceneContextMenuEvent::screenPos() const
908
Q_D(const QGraphicsSceneContextMenuEvent);
913
\fn void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &point)
916
Sets the position associated with the context menu to the given \a point
917
in screen coordinates.
919
void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &pos)
921
Q_D(QGraphicsSceneContextMenuEvent);
926
Returns the keyboard modifiers in use when the context menu was requested.
928
Qt::KeyboardModifiers QGraphicsSceneContextMenuEvent::modifiers() const
930
Q_D(const QGraphicsSceneContextMenuEvent);
937
Sets the keyboard modifiers associated with the context menu to the \a
940
void QGraphicsSceneContextMenuEvent::setModifiers(Qt::KeyboardModifiers modifiers)
942
Q_D(QGraphicsSceneContextMenuEvent);
943
d->modifiers = modifiers;
947
Returns the reason for the context menu event.
949
\sa QGraphicsSceneContextMenuEvent::Reason
951
QGraphicsSceneContextMenuEvent::Reason QGraphicsSceneContextMenuEvent::reason() const
953
Q_D(const QGraphicsSceneContextMenuEvent);
959
Sets the reason for the context menu event to \a reason.
963
void QGraphicsSceneContextMenuEvent::setReason(Reason reason)
965
Q_D(QGraphicsSceneContextMenuEvent);
969
class QGraphicsSceneHoverEventPrivate : public QGraphicsSceneEventPrivate
976
QPointF lastScenePos;
977
QPoint lastScreenPos;
978
Qt::KeyboardModifiers modifiers;
984
Constructs a graphics scene hover event of the specified \a type.
986
QGraphicsSceneHoverEvent::QGraphicsSceneHoverEvent(Type type)
987
: QGraphicsSceneEvent(*new QGraphicsSceneHoverEventPrivate, type)
994
QGraphicsSceneHoverEvent::~QGraphicsSceneHoverEvent()
999
Returns the position of the mouse cursor in item coordinates at the moment
1000
the hover event was sent.
1002
\sa scenePos(), screenPos()
1004
QPointF QGraphicsSceneHoverEvent::pos() const
1006
Q_D(const QGraphicsSceneHoverEvent);
1011
\fn void QGraphicsSceneHoverEvent::setPos(const QPointF &point)
1014
Sets the position associated with the hover event to the given \a point in
1017
void QGraphicsSceneHoverEvent::setPos(const QPointF &pos)
1019
Q_D(QGraphicsSceneHoverEvent);
1024
Returns the position of the mouse cursor in scene coordinates at the
1025
moment the hover event was sent.
1027
\sa pos(), screenPos()
1029
QPointF QGraphicsSceneHoverEvent::scenePos() const
1031
Q_D(const QGraphicsSceneHoverEvent);
1036
\fn void QGraphicsSceneHoverEvent::setScenePos(const QPointF &point)
1039
Sets the position associated with the hover event to the given \a point in
1042
void QGraphicsSceneHoverEvent::setScenePos(const QPointF &pos)
1044
Q_D(QGraphicsSceneHoverEvent);
1049
Returns the position of the mouse cursor in screen coordinates at the
1050
moment the hover event was sent.
1052
\sa pos(), scenePos()
1054
QPoint QGraphicsSceneHoverEvent::screenPos() const
1056
Q_D(const QGraphicsSceneHoverEvent);
1057
return d->screenPos;
1061
\fn void QGraphicsSceneHoverEvent::setScreenPos(const QPoint &point)
1064
Sets the position associated with the hover event to the given \a point in
1067
void QGraphicsSceneHoverEvent::setScreenPos(const QPoint &pos)
1069
Q_D(QGraphicsSceneHoverEvent);
1076
Returns the last recorded mouse cursor position in item coordinates.
1078
\sa lastScenePos(), lastScreenPos(), pos()
1080
QPointF QGraphicsSceneHoverEvent::lastPos() const
1082
Q_D(const QGraphicsSceneHoverEvent);
1089
void QGraphicsSceneHoverEvent::setLastPos(const QPointF &pos)
1091
Q_D(QGraphicsSceneHoverEvent);
1098
Returns the last recorded, the scene coordinates of the previous mouse or
1099
hover event received by the view, that created the event mouse cursor
1100
position in scene coordinates.
1102
\sa lastPos(), lastScreenPos(), scenePos()
1104
QPointF QGraphicsSceneHoverEvent::lastScenePos() const
1106
Q_D(const QGraphicsSceneHoverEvent);
1107
return d->lastScenePos;
1113
void QGraphicsSceneHoverEvent::setLastScenePos(const QPointF &pos)
1115
Q_D(QGraphicsSceneHoverEvent);
1116
d->lastScenePos = pos;
1122
Returns the last recorded mouse cursor position in screen coordinates. The
1123
last recorded position is the position of the previous mouse or hover
1124
event received by the view that created the event.
1126
\sa lastPos(), lastScenePos(), screenPos()
1128
QPoint QGraphicsSceneHoverEvent::lastScreenPos() const
1130
Q_D(const QGraphicsSceneHoverEvent);
1131
return d->lastScreenPos;
1137
void QGraphicsSceneHoverEvent::setLastScreenPos(const QPoint &pos)
1139
Q_D(QGraphicsSceneHoverEvent);
1140
d->lastScreenPos = pos;
1146
Returns the keyboard modifiers at the moment the hover event was sent.
1148
Qt::KeyboardModifiers QGraphicsSceneHoverEvent::modifiers() const
1150
Q_D(const QGraphicsSceneHoverEvent);
1151
return d->modifiers;
1155
\fn void QGraphicsSceneHoverEvent::setModifiers(Qt::KeyboardModifiers modifiers)
1158
Sets the modifiers for the current hover event to \a modifiers.
1160
void QGraphicsSceneHoverEvent::setModifiers(Qt::KeyboardModifiers modifiers)
1162
Q_D(QGraphicsSceneHoverEvent);
1163
d->modifiers = modifiers;
1166
class QGraphicsSceneHelpEventPrivate : public QGraphicsSceneEventPrivate
1176
Constructs a graphics scene help event of the specified \a type.
1178
QGraphicsSceneHelpEvent::QGraphicsSceneHelpEvent(Type type)
1179
: QGraphicsSceneEvent(*new QGraphicsSceneHelpEventPrivate, type)
1186
QGraphicsSceneHelpEvent::~QGraphicsSceneHelpEvent()
1191
Returns the position of the mouse cursor in scene coordinates at the
1192
moment the help event was sent.
1196
QPointF QGraphicsSceneHelpEvent::scenePos() const
1198
Q_D(const QGraphicsSceneHelpEvent);
1203
\fn void QGraphicsSceneHelpEvent::setScenePos(const QPointF &point)
1206
Sets the position associated with the context menu to the given \a point
1207
in scene coordinates.
1209
void QGraphicsSceneHelpEvent::setScenePos(const QPointF &pos)
1211
Q_D(QGraphicsSceneHelpEvent);
1216
Returns the position of the mouse cursor in screen coordinates at the
1217
moment the help event was sent.
1221
QPoint QGraphicsSceneHelpEvent::screenPos() const
1223
Q_D(const QGraphicsSceneHelpEvent);
1224
return d->screenPos;
1228
\fn void QGraphicsSceneHelpEvent::setScreenPos(const QPoint &point)
1231
Sets the position associated with the context menu to the given \a point
1232
in screen coordinates.
1234
void QGraphicsSceneHelpEvent::setScreenPos(const QPoint &pos)
1236
Q_D(QGraphicsSceneHelpEvent);
1240
class QGraphicsSceneDragDropEventPrivate : public QGraphicsSceneEventPrivate
1242
Q_DECLARE_PUBLIC(QGraphicsSceneDragDropEvent)
1244
inline QGraphicsSceneDragDropEventPrivate()
1245
: source(0), mimeData(0)
1251
Qt::MouseButtons buttons;
1252
Qt::KeyboardModifiers modifiers;
1253
Qt::DropActions possibleActions;
1254
Qt::DropAction proposedAction;
1255
Qt::DropAction dropAction;
1257
const QMimeData *mimeData;
1263
Constructs a new QGraphicsSceneDragDropEvent of the
1264
specified \a type. The type can be either
1265
QEvent::GraphicsSceneDragEnter, QEvent::GraphicsSceneDragLeave,
1266
QEvent::GraphicsSceneDragMove, or QEvent::GraphicsSceneDrop.
1268
QGraphicsSceneDragDropEvent::QGraphicsSceneDragDropEvent(Type type)
1269
: QGraphicsSceneEvent(*new QGraphicsSceneDragDropEventPrivate, type)
1274
Destroys the object.
1276
QGraphicsSceneDragDropEvent::~QGraphicsSceneDragDropEvent()
1281
Returns the mouse position of the event relative to the
1282
view that sent the event.
1284
\sa QGraphicsView, screenPos(), scenePos()
1286
QPointF QGraphicsSceneDragDropEvent::pos() const
1288
Q_D(const QGraphicsSceneDragDropEvent);
1294
Sets the position of the mouse to \a pos; this should be
1295
relative to the widget that generated the event, which normally
1298
\sa pos(), setScenePos(), setScreenPos()
1301
void QGraphicsSceneDragDropEvent::setPos(const QPointF &pos)
1303
Q_D(QGraphicsSceneDragDropEvent);
1308
Returns the position of the mouse in scene coordinates.
1310
\sa pos(), screenPos()
1312
QPointF QGraphicsSceneDragDropEvent::scenePos() const
1314
Q_D(const QGraphicsSceneDragDropEvent);
1320
Sets the scene position of the mouse to \a pos.
1322
\sa scenePos(), setScreenPos(), setPos()
1324
void QGraphicsSceneDragDropEvent::setScenePos(const QPointF &pos)
1326
Q_D(QGraphicsSceneDragDropEvent);
1331
Returns the position of the mouse relative to the screen.
1333
\sa pos(), scenePos()
1335
QPoint QGraphicsSceneDragDropEvent::screenPos() const
1337
Q_D(const QGraphicsSceneDragDropEvent);
1338
return d->screenPos;
1343
Sets the mouse position relative to the screen to \a pos.
1345
\sa screenPos(), setScenePos(), setPos()
1347
void QGraphicsSceneDragDropEvent::setScreenPos(const QPoint &pos)
1349
Q_D(QGraphicsSceneDragDropEvent);
1354
Returns a Qt::MouseButtons value indicating which buttons
1355
were pressed on the mouse when this mouse event was
1358
\sa Qt::MouseButtons
1360
Qt::MouseButtons QGraphicsSceneDragDropEvent::buttons() const
1362
Q_D(const QGraphicsSceneDragDropEvent);
1368
Sets the mouse buttons that were pressed when the event was
1369
created to \a buttons.
1371
\sa Qt::MouseButtons, buttons()
1373
void QGraphicsSceneDragDropEvent::setButtons(Qt::MouseButtons buttons)
1375
Q_D(QGraphicsSceneDragDropEvent);
1376
d->buttons = buttons;
1380
Returns the keyboard modifiers that were pressed when the drag
1381
and drop event was created.
1383
\sa Qt::KeyboardModifiers
1385
Qt::KeyboardModifiers QGraphicsSceneDragDropEvent::modifiers() const
1387
Q_D(const QGraphicsSceneDragDropEvent);
1388
return d->modifiers;
1393
Sets the keyboard modifiers that were pressed when the event
1394
was created to \a modifiers.
1396
\sa Qt::KeyboardModifiers, modifiers()
1399
void QGraphicsSceneDragDropEvent::setModifiers(Qt::KeyboardModifiers modifiers)
1401
Q_D(QGraphicsSceneDragDropEvent);
1402
d->modifiers = modifiers;
1406
Returns the possible drop actions that the drag and
1412
Qt::DropActions QGraphicsSceneDragDropEvent::possibleActions() const
1414
Q_D(const QGraphicsSceneDragDropEvent);
1415
return d->possibleActions;
1420
Sets the possible drop actions that the drag can
1421
result in to \a actions.
1423
\sa Qt::DropActions, possibleActions()
1425
void QGraphicsSceneDragDropEvent::setPossibleActions(Qt::DropActions actions)
1427
Q_D(QGraphicsSceneDragDropEvent);
1428
d->possibleActions = actions;
1432
Returns the drop action that is proposed, i.e., preferred.
1433
The action must be one of the possible actions as defined by
1434
\c possibleActions().
1436
\sa Qt::DropAction, possibleActions()
1439
Qt::DropAction QGraphicsSceneDragDropEvent::proposedAction() const
1441
Q_D(const QGraphicsSceneDragDropEvent);
1442
return d->proposedAction;
1447
Sets the proposed action to \a action. The proposed action
1448
is a Qt::DropAction that is one of the possible actions as
1449
given by \c possibleActions().
1451
\sa proposedAction(), Qt::DropAction, possibleActions()
1454
void QGraphicsSceneDragDropEvent::setProposedAction(Qt::DropAction action)
1456
Q_D(QGraphicsSceneDragDropEvent);
1457
d->proposedAction = action;
1461
Sets the proposed action as accepted, i.e, the drop action
1462
is set to the proposed action. This is equal to:
1464
\snippet code/src_gui_graphicsview_qgraphicssceneevent.cpp 0
1466
When using this function, one should not call \c accept().
1468
\sa dropAction(), setDropAction(), proposedAction()
1471
void QGraphicsSceneDragDropEvent::acceptProposedAction()
1473
Q_D(QGraphicsSceneDragDropEvent);
1474
d->dropAction = d->proposedAction;
1478
Returns the action that was performed in this drag and drop.
1479
This should be set by the receiver of the drop and is
1480
returned by QDrag::exec().
1482
\sa setDropAction(), acceptProposedAction()
1485
Qt::DropAction QGraphicsSceneDragDropEvent::dropAction() const
1487
Q_D(const QGraphicsSceneDragDropEvent);
1488
return d->dropAction;
1492
This function lets the receiver of the drop set the drop
1493
action that was performed to \a action, which should be one
1495
\l{QGraphicsSceneDragDropEvent::possibleActions()}{possible
1496
actions}. Call \c accept() in stead of \c
1497
acceptProposedAction() if you use this function.
1499
\sa dropAction(), accept(), possibleActions()
1501
void QGraphicsSceneDragDropEvent::setDropAction(Qt::DropAction action)
1503
Q_D(QGraphicsSceneDragDropEvent);
1504
d->dropAction = action;
1508
This function returns the QGraphicsView that created the
1509
QGraphicsSceneDragDropEvent.
1511
QWidget *QGraphicsSceneDragDropEvent::source() const
1513
Q_D(const QGraphicsSceneDragDropEvent);
1519
This function set the source widget, i.e., the widget that
1520
created the drop event, to \a source.
1522
void QGraphicsSceneDragDropEvent::setSource(QWidget *source)
1524
Q_D(QGraphicsSceneDragDropEvent);
1529
This function returns the MIME data of the event.
1531
const QMimeData *QGraphicsSceneDragDropEvent::mimeData() const
1533
Q_D(const QGraphicsSceneDragDropEvent);
1539
This function sets the MIME data for the event.
1541
void QGraphicsSceneDragDropEvent::setMimeData(const QMimeData *data)
1543
Q_D(QGraphicsSceneDragDropEvent);
1547
class QGraphicsSceneResizeEventPrivate : public QGraphicsSceneEventPrivate
1549
Q_DECLARE_PUBLIC(QGraphicsSceneResizeEvent)
1551
inline QGraphicsSceneResizeEventPrivate()
1559
Constructs a QGraphicsSceneResizeEvent.
1561
QGraphicsSceneResizeEvent::QGraphicsSceneResizeEvent()
1562
: QGraphicsSceneEvent(*new QGraphicsSceneResizeEventPrivate, QEvent::GraphicsSceneResize)
1567
Destroys the QGraphicsSceneResizeEvent.
1569
QGraphicsSceneResizeEvent::~QGraphicsSceneResizeEvent()
1574
Returns the old size (i.e., the size immediately before the widget was
1577
\sa newSize(), QGraphicsWidget::resize()
1579
QSizeF QGraphicsSceneResizeEvent::oldSize() const
1581
Q_D(const QGraphicsSceneResizeEvent);
1588
void QGraphicsSceneResizeEvent::setOldSize(const QSizeF &size)
1590
Q_D(QGraphicsSceneResizeEvent);
1595
Returns the new size (i.e., the current size).
1597
\sa oldSize(), QGraphicsWidget::resize()
1599
QSizeF QGraphicsSceneResizeEvent::newSize() const
1601
Q_D(const QGraphicsSceneResizeEvent);
1608
void QGraphicsSceneResizeEvent::setNewSize(const QSizeF &size)
1610
Q_D(QGraphicsSceneResizeEvent);
1614
class QGraphicsSceneMoveEventPrivate : public QGraphicsSceneEventPrivate
1616
Q_DECLARE_PUBLIC(QGraphicsSceneMoveEvent)
1618
inline QGraphicsSceneMoveEventPrivate()
1626
Constructs a QGraphicsSceneMoveEvent.
1628
QGraphicsSceneMoveEvent::QGraphicsSceneMoveEvent()
1629
: QGraphicsSceneEvent(*new QGraphicsSceneMoveEventPrivate, QEvent::GraphicsSceneMove)
1634
Destroys the QGraphicsSceneMoveEvent.
1636
QGraphicsSceneMoveEvent::~QGraphicsSceneMoveEvent()
1641
Returns the old position (i.e., the position immediately before the widget
1644
\sa newPos(), QGraphicsItem::setPos()
1646
QPointF QGraphicsSceneMoveEvent::oldPos() const
1648
Q_D(const QGraphicsSceneMoveEvent);
1655
void QGraphicsSceneMoveEvent::setOldPos(const QPointF &pos)
1657
Q_D(QGraphicsSceneMoveEvent);
1662
Returns the new position (i.e., the current position).
1664
\sa oldPos(), QGraphicsItem::setPos()
1666
QPointF QGraphicsSceneMoveEvent::newPos() const
1668
Q_D(const QGraphicsSceneMoveEvent);
1675
void QGraphicsSceneMoveEvent::setNewPos(const QPointF &pos)
1677
Q_D(QGraphicsSceneMoveEvent);
1683
#endif // QT_NO_GRAPHICSVIEW