Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgraphicssceneevent.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5/*!
6 \class QGraphicsSceneEvent
7 \brief The QGraphicsSceneEvent class provides a base class for all
8 graphics view related events.
9 \since 4.2
10 \ingroup graphicsview-api
11 \inmodule QtWidgets
12
13 When a QGraphicsView receives Qt mouse, keyboard, and drag and
14 drop events (QMouseEvent, QKeyEvent, QDragEvent, etc.), it
15 translates them into instances of QGraphicsSceneEvent subclasses
16 and forwards them to the QGraphicsScene it displays. The scene
17 then forwards the events to the relevant items.
18
19 For example, when a QGraphicsView receives a QMouseEvent of type
20 MousePress as a response to a user click, the view sends a
21 QGraphicsSceneMouseEvent of type GraphicsSceneMousePress to the
22 underlying QGraphicsScene through its
23 \l{QGraphicsScene::}{mousePressEvent()} function. The default
24 QGraphicsScene::mousePressEvent() implementation determines which
25 item was clicked and forwards the event to
26 QGraphicsItem::mousePressEvent().
27
28 \omit ### Beskrive widget() \endomit
29
30 Subclasses such as QGraphicsSceneMouseEvent and
31 QGraphicsSceneContextMenuEvent provide the coordinates from the
32 original QEvent in screen, scene, and item coordinates (see
33 \l{QGraphicsSceneMouseEvent::}{screenPos()},
34 \l{QGraphicsSceneMouseEvent::}{scenePos()}, and
35 \l{QGraphicsSceneMouseEvent::}{pos()}). The item coordinates are
36 set by the QGraphicsScene before it forwards the event to the
37 event to a QGraphicsItem. The mouse events also add the
38 possibility to retrieve the coordinates from the last event
39 received by the view (see
40 \l{QGraphicsSceneMouseEvent::}{lastScreenPos()},
41 \l{QGraphicsSceneMouseEvent::}{lastScenePos()}, and
42 \l{QGraphicsSceneMouseEvent::}{lastPos()}).
43
44 \sa QEvent
45*/
46
47/*!
48 \class QGraphicsSceneMouseEvent
49 \brief The QGraphicsSceneMouseEvent class provides mouse events
50 in the graphics view framework.
51 \since 4.2
52 \ingroup graphicsview-api
53 \inmodule QtWidgets
54
55 When a QGraphicsView receives a QMouseEvent, it translates it to a
56 QGraphicsSceneMouseEvent. The event is then forwarded to the
57 QGraphicsScene associated with the view. If the event is not
58 handled by the scene, the view may use it, e.g., for the
59 \l{QGraphicsView::}{DragMode}.
60
61 In addition to containing the item, scene, and screen coordinates
62 of the event (as pos(), scenePos(), and screenPos()), mouse
63 events also contain the coordinates of the previous mouse
64 event received by the view. These can be retrieved with
65 lastPos(), lastScreenPos(), and lastScenePos().
66
67 \sa QGraphicsSceneContextMenuEvent,
68 QGraphicsSceneHoverEvent, QGraphicsSceneWheelEvent,
69 QMouseEvent
70*/
71
72/*!
73 \class QGraphicsSceneWheelEvent
74 \brief The QGraphicsSceneWheelEvent class provides wheel events
75 in the graphics view framework.
76 \brief The QGraphicsSceneWheelEvent class provides wheel events in the
77 graphics view framework.
78 \since 4.2
79 \ingroup graphicsview-api
80 \inmodule QtWidgets
81
82 \l{QWheelEvent}{QWheelEvent}s received by a QGraphicsView are translated
83 into QGraphicsSceneWheelEvents; it translates the QWheelEvent::globalPos()
84 into item, scene, and screen coordinates (pos(), scenePos(), and
85 screenPos()).
86
87 \sa QGraphicsSceneMouseEvent, QGraphicsSceneContextMenuEvent,
88 QGraphicsSceneHoverEvent, QWheelEvent
89*/
90
91/*!
92 \class QGraphicsSceneContextMenuEvent
93 \brief The QGraphicsSceneContextMenuEvent class provides context
94 menu events in the graphics view framework.
95 \since 4.2
96 \ingroup graphicsview-api
97 \inmodule QtWidgets
98
99 A QContextMenuEvent received by a QGraphicsView is translated
100 into a QGraphicsSceneContextMenuEvent. The
101 QContextMenuEvent::globalPos() is translated into item, scene, and
102 screen coordinates (pos(), scenePos(), and screenPos()).
103
104 \sa QGraphicsSceneMouseEvent, QGraphicsSceneWheelEvent,
105 QContextMenuEvent
106*/
107
108/*!
109 \enum QGraphicsSceneContextMenuEvent::Reason
110
111 This enum describes the reason why the context event was sent.
112
113 \value Mouse The mouse caused the event to be sent. On most
114 platforms, this means the right mouse button was clicked.
115
116 \value Keyboard The keyboard caused this event to be sent. On
117 Windows and \macos, this means the menu button was pressed.
118
119 \value Other The event was sent by some other means (i.e. not
120 by the mouse or keyboard).
121*/
122
123/*!
124 \class QGraphicsSceneHoverEvent
125 \brief The QGraphicsSceneHoverEvent class provides hover events
126 in the graphics view framework.
127 \since 4.2
128 \ingroup graphicsview-api
129 \inmodule QtWidgets
130
131 When a QGraphicsView receives a QHoverEvent event, it translates
132 it into QGraphicsSceneHoverEvent. The event is then forwarded to
133 the QGraphicsScene associated with the view.
134
135 \sa QGraphicsSceneMouseEvent, QGraphicsSceneContextMenuEvent,
136 QGraphicsSceneWheelEvent, QHoverEvent
137*/
138
139/*!
140 \class QGraphicsSceneHelpEvent
141 \brief The QGraphicsSceneHelpEvent class provides events when a
142 tooltip is requested.
143 \since 4.2
144 \ingroup graphicsview-api
145 \inmodule QtWidgets
146
147 When a QGraphicsView receives a QEvent of type
148 QEvent::ToolTip, it creates a QGraphicsSceneHelpEvent, which is
149 forwarded to the scene. You can set a tooltip on a QGraphicsItem
150 with \l{QGraphicsItem::}{setToolTip()}; by default QGraphicsScene
151 displays the tooltip of the QGraphicsItem with the highest
152 z-value (i.e, the top-most item) under the mouse position.
153
154 QGraphicsView does not forward events when
155 \l{QWhatsThis}{"What's This"} and \l{QStatusTipEvent}{status tip}
156 help is requested. If you need this, you can reimplement
157 QGraphicsView::viewportEvent() and forward QStatusTipEvent
158 events and \l{QEvent}{QEvents} of type QEvent::WhatsThis to the
159 scene.
160
161 \sa QEvent
162*/
163
164/*!
165 \class QGraphicsSceneDragDropEvent
166 \brief The QGraphicsSceneDragDropEvent class provides events for
167 drag and drop in the graphics view framework.
168 \since 4.2
169 \ingroup graphicsview-api
170 \inmodule QtWidgets
171
172 QGraphicsView inherits the drag and drop functionality provided
173 by QWidget. When it receives a drag and drop event, it translates
174 it to a QGraphicsSceneDragDropEvent.
175
176 QGraphicsSceneDragDropEvent stores events of type
177 GraphicsSceneDragEnter, GraphicsSceneDragLeave,
178 GraphicsSceneDragMove, or GraphicsSceneDrop.
179
180 QGraphicsSceneDragDropEvent contains the position of the mouse
181 cursor in both item, scene, and screen coordinates; this can be
182 retrieved with pos(), scenePos(), and screenPos().
183
184 The scene sends the event to the first QGraphicsItem under the
185 mouse cursor that accepts drops; a graphics item is set to accept
186 drops with \l{QGraphicsItem::}{setAcceptDrops()}.
187*/
188
189/*!
190 \class QGraphicsSceneResizeEvent
191 \brief The QGraphicsSceneResizeEvent class provides events for widget
192 resizing in the graphics view framework.
193 \since 4.4
194 \ingroup graphicsview-api
195 \inmodule QtWidgets
196
197 A QGraphicsWidget sends itself a QGraphicsSceneResizeEvent immediately
198 when its geometry changes.
199
200 It's similar to QResizeEvent, but its sizes, oldSize() and newSize(), use
201 QSizeF instead of QSize.
202
203 \sa QGraphicsWidget::setGeometry(), QGraphicsWidget::resize()
204*/
205
206/*!
207 \class QGraphicsSceneMoveEvent
208 \brief The QGraphicsSceneMoveEvent class provides events for widget
209 moving in the graphics view framework.
210 \since 4.4
211 \ingroup graphicsview-api
212 \inmodule QtWidgets
213
214 A QGraphicsWidget sends itself a QGraphicsSceneMoveEvent immediately when
215 its local position changes. The delivery is implemented as part of
216 QGraphicsItem::itemChange().
217
218 It's similar to QMoveEvent, but its positions, oldPos() and newPos(), use
219 QPointF instead of QPoint.
220
221 \sa QGraphicsItem::setPos(), QGraphicsItem::ItemPositionChange,
222 QGraphicsItem::ItemPositionHasChanged
223*/
224
226
227#ifndef QT_NO_DEBUG_STREAM
228#include <QtCore/qdebug.h>
229#include <private/qdebug_p.h>
230#endif
231#include <QtCore/qmap.h>
232#include <QtCore/qpoint.h>
233#include <QtCore/qsize.h>
234#include <QtCore/qstring.h>
235#include "qgraphicsview.h"
236#include "qgraphicsitem.h"
237#include <QtWidgets/qgesture.h>
238#include <private/qevent_p.h>
239
240QT_BEGIN_NAMESPACE
241
242class QGraphicsSceneEventPrivate
243{
244public:
245 inline QGraphicsSceneEventPrivate()
246 : widget(nullptr),
247 q_ptr(nullptr)
248 { }
249
250 inline virtual ~QGraphicsSceneEventPrivate()
251 { }
252
253 QWidget *widget;
254 QGraphicsSceneEvent *q_ptr;
255 quint64 timestamp = 0;
256};
257
258/*!
259 \internal
260
261 Constructs a generic graphics scene event of the specified \a type.
262*/
263QGraphicsSceneEvent::QGraphicsSceneEvent(Type type)
264 : QEvent(type), d_ptr(new QGraphicsSceneEventPrivate)
265{
266 d_ptr->q_ptr = this;
267}
268
269/*!
270 \internal
271
272 Constructs a generic graphics scene event.
273*/
274QGraphicsSceneEvent::QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type)
275 : QEvent(type), d_ptr(&dd)
276{
277 d_ptr->q_ptr = this;
278}
279
280/*!
281 Destroys the event.
282*/
283QGraphicsSceneEvent::~QGraphicsSceneEvent()
284{
285}
286
287/*!
288 Returns the widget where the event originated, or \nullptr if the
289 event originates from another application.
290*/
291QWidget *QGraphicsSceneEvent::widget() const
292{
293 return d_ptr->widget;
294}
295
296/*!
297 \internal
298
299 Sets the \a widget related to this event.
300
301 \sa widget()
302*/
303void QGraphicsSceneEvent::setWidget(QWidget *widget)
304{
305 d_ptr->widget = widget;
306}
307
308/*!
309 \since 6.2
310
311 Returns the timestamp of the original event, or 0 if the
312 original event does not report a time stamp.
313*/
314quint64 QGraphicsSceneEvent::timestamp() const
315{
316 return d_ptr->timestamp;
317}
318/*!
319 \internal
320
321 Sets the timestamp for the event to \a ts.
322*/
323void QGraphicsSceneEvent::setTimestamp(quint64 ts)
324{
325 d_ptr->timestamp = ts;
326}
327
351
352/*!
353 \internal
354
355 Constructs a generic graphics scene mouse event of the specified \a type.
356*/
357QGraphicsSceneMouseEvent::QGraphicsSceneMouseEvent(Type type)
358 : QGraphicsSceneEvent(*new QGraphicsSceneMouseEventPrivate, type)
359{
360}
361
362/*!
363 Destroys the event.
364*/
365QGraphicsSceneMouseEvent::~QGraphicsSceneMouseEvent()
366{
367}
368
369/*!
370 Returns the mouse cursor position in item coordinates.
371
372 \sa scenePos(), screenPos(), lastPos()
373*/
374QPointF QGraphicsSceneMouseEvent::pos() const
375{
376 Q_D(const QGraphicsSceneMouseEvent);
377 return d->pos;
378}
379
380/*!
381 \internal
382*/
383void QGraphicsSceneMouseEvent::setPos(const QPointF &pos)
384{
385 Q_D(QGraphicsSceneMouseEvent);
386 d->pos = pos;
387}
388
389/*!
390 Returns the mouse cursor position in scene coordinates.
391
392 \sa pos(), screenPos(), lastScenePos()
393*/
394QPointF QGraphicsSceneMouseEvent::scenePos() const
395{
396 Q_D(const QGraphicsSceneMouseEvent);
397 return d->scenePos;
398}
399
400/*!
401 \internal
402*/
403void QGraphicsSceneMouseEvent::setScenePos(const QPointF &pos)
404{
405 Q_D(QGraphicsSceneMouseEvent);
406 d->scenePos = pos;
407}
408
409/*!
410 Returns the mouse cursor position in screen coordinates.
411
412 \sa pos(), scenePos(), lastScreenPos()
413*/
414QPoint QGraphicsSceneMouseEvent::screenPos() const
415{
416 Q_D(const QGraphicsSceneMouseEvent);
417 return d->screenPos;
418}
419
420/*!
421 \internal
422*/
423void QGraphicsSceneMouseEvent::setScreenPos(const QPoint &pos)
424{
425 Q_D(QGraphicsSceneMouseEvent);
426 d->screenPos = pos;
427}
428
429/*!
430 Returns the mouse cursor position in item coordinates where the specified
431 \a button was clicked.
432
433 \sa buttonDownScenePos(), buttonDownScreenPos(), pos()
434*/
435QPointF QGraphicsSceneMouseEvent::buttonDownPos(Qt::MouseButton button) const
436{
437 Q_D(const QGraphicsSceneMouseEvent);
438 return d->buttonDownPos.value(button);
439}
440
441/*!
442 \internal
443*/
444void QGraphicsSceneMouseEvent::setButtonDownPos(Qt::MouseButton button, const QPointF &pos)
445{
446 Q_D(QGraphicsSceneMouseEvent);
447 d->buttonDownPos.insert(button, pos);
448}
449
450/*!
451 Returns the mouse cursor position in scene coordinates where the
452 specified \a button was clicked.
453
454 \sa buttonDownPos(), buttonDownScreenPos(), scenePos()
455*/
456QPointF QGraphicsSceneMouseEvent::buttonDownScenePos(Qt::MouseButton button) const
457{
458 Q_D(const QGraphicsSceneMouseEvent);
459 return d->buttonDownScenePos.value(button);
460}
461
462/*!
463 \internal
464*/
465void QGraphicsSceneMouseEvent::setButtonDownScenePos(Qt::MouseButton button, const QPointF &pos)
466{
467 Q_D(QGraphicsSceneMouseEvent);
468 d->buttonDownScenePos.insert(button, pos);
469}
470
471/*!
472 Returns the mouse cursor position in screen coordinates where the
473 specified \a button was clicked.
474
475 \sa screenPos(), buttonDownPos(), buttonDownScenePos()
476*/
477QPoint QGraphicsSceneMouseEvent::buttonDownScreenPos(Qt::MouseButton button) const
478{
479 Q_D(const QGraphicsSceneMouseEvent);
480 return d->buttonDownScreenPos.value(button);
481}
482
483/*!
484 \internal
485*/
486void QGraphicsSceneMouseEvent::setButtonDownScreenPos(Qt::MouseButton button, const QPoint &pos)
487{
488 Q_D(QGraphicsSceneMouseEvent);
489 d->buttonDownScreenPos.insert(button, pos);
490}
491
492/*!
493 Returns the last recorded mouse cursor position in item
494 coordinates.
495
496 \sa lastScenePos(), lastScreenPos(), pos()
497*/
498QPointF QGraphicsSceneMouseEvent::lastPos() const
499{
500 Q_D(const QGraphicsSceneMouseEvent);
501 return d->lastPos;
502}
503
504/*!
505 \internal
506*/
507void QGraphicsSceneMouseEvent::setLastPos(const QPointF &pos)
508{
509 Q_D(QGraphicsSceneMouseEvent);
510 d->lastPos = pos;
511}
512
513/*!
514 Returns the last recorded mouse cursor position in scene
515 coordinates. The last recorded position is the position of
516 the previous mouse event received by the view that created
517 the event.
518
519 \sa lastPos(), lastScreenPos(), scenePos()
520*/
521QPointF QGraphicsSceneMouseEvent::lastScenePos() const
522{
523 Q_D(const QGraphicsSceneMouseEvent);
524 return d->lastScenePos;
525}
526
527/*!
528 \internal
529*/
530void QGraphicsSceneMouseEvent::setLastScenePos(const QPointF &pos)
531{
532 Q_D(QGraphicsSceneMouseEvent);
533 d->lastScenePos = pos;
534}
535
536/*!
537 Returns the last recorded mouse cursor position in screen
538 coordinates. The last recorded position is the position of
539 the previous mouse event received by the view that created
540 the event.
541
542 \sa lastPos(), lastScenePos(), screenPos()
543*/
544QPoint QGraphicsSceneMouseEvent::lastScreenPos() const
545{
546 Q_D(const QGraphicsSceneMouseEvent);
547 return d->lastScreenPos;
548}
549
550/*!
551 \internal
552*/
553void QGraphicsSceneMouseEvent::setLastScreenPos(const QPoint &pos)
554{
555 Q_D(QGraphicsSceneMouseEvent);
556 d->lastScreenPos = pos;
557}
558
559/*!
560 Returns the combination of mouse buttons that were pressed at the
561 time the event was sent.
562
563 \sa button(), modifiers()
564*/
565Qt::MouseButtons QGraphicsSceneMouseEvent::buttons() const
566{
567 Q_D(const QGraphicsSceneMouseEvent);
568 return d->buttons;
569}
570
571/*!
572 \internal
573*/
574void QGraphicsSceneMouseEvent::setButtons(Qt::MouseButtons buttons)
575{
576 Q_D(QGraphicsSceneMouseEvent);
577 d->buttons = buttons;
578}
579
580/*!
581 Returns the mouse button (if any) that caused the event.
582
583 \sa buttons(), modifiers()
584*/
585Qt::MouseButton QGraphicsSceneMouseEvent::button() const
586{
587 Q_D(const QGraphicsSceneMouseEvent);
588 return d->button;
589}
590
591/*!
592 \internal
593*/
594void QGraphicsSceneMouseEvent::setButton(Qt::MouseButton button)
595{
596 Q_D(QGraphicsSceneMouseEvent);
597 d->button = button;
598}
599
600/*!
601 Returns the keyboard modifiers in use at the time the event was
602 sent.
603
604 \sa buttons(), button()
605*/
606Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers() const
607{
608 Q_D(const QGraphicsSceneMouseEvent);
609 return d->modifiers;
610}
611
612/*!
613 \since 5.4
614
615 Returns information about the mouse event source.
616
617 The mouse event source can be used to distinguish between genuine
618 and artificial mouse events. The latter are events that are
619 synthesized from touch events by the operating system or Qt itself.
620
621 \sa Qt::MouseEventSource
622 \sa QMouseEvent::source()
623 */
624Qt::MouseEventSource QGraphicsSceneMouseEvent::source() const
625{
626 Q_D(const QGraphicsSceneMouseEvent);
627 return d->source;
628}
629
630/*!
631 \since 5.4
632 \internal
633 */
634void QGraphicsSceneMouseEvent::setSource(Qt::MouseEventSource source)
635{
636 Q_D(QGraphicsSceneMouseEvent);
637 d->source = source;
638}
639
640/*!
641 \since 5.4
642
643 Returns the mouse event flags.
644
645 The mouse event flags provide additional information about a mouse event.
646
647 \sa Qt::MouseEventFlag
648 \sa QMouseEvent::flags()
649 */
650Qt::MouseEventFlags QGraphicsSceneMouseEvent::flags() const
651{
652 Q_D(const QGraphicsSceneMouseEvent);
653 return d->flags;
654}
655
656/*!
657 \since 5.4
658 \internal
659 */
660void QGraphicsSceneMouseEvent::setFlags(Qt::MouseEventFlags flags)
661{
662 Q_D(QGraphicsSceneMouseEvent);
663 d->flags = flags;
664}
665
666/*!
667 \internal
668*/
669void QGraphicsSceneMouseEvent::setModifiers(Qt::KeyboardModifiers modifiers)
670{
671 Q_D(QGraphicsSceneMouseEvent);
672 d->modifiers = modifiers;
673}
674
692
693/*!
694 \internal
695
696 Constructs a QGraphicsSceneWheelEvent of type \a type, which
697 is always QEvent::GraphicsSceneWheel.
698*/
699QGraphicsSceneWheelEvent::QGraphicsSceneWheelEvent(Type type)
700 : QGraphicsSceneEvent(*new QGraphicsSceneWheelEventPrivate, type)
701{
702}
703
704/*!
705 Destroys the QGraphicsSceneWheelEvent.
706*/
707QGraphicsSceneWheelEvent::~QGraphicsSceneWheelEvent()
708{
709}
710
711/*!
712 Returns the position of the cursor in item coordinates when the
713 wheel event occurred.
714
715 \sa scenePos(), screenPos()
716*/
717QPointF QGraphicsSceneWheelEvent::pos() const
718{
719 Q_D(const QGraphicsSceneWheelEvent);
720 return d->pos;
721}
722
723/*!
724 \internal
725*/
726void QGraphicsSceneWheelEvent::setPos(const QPointF &pos)
727{
728 Q_D(QGraphicsSceneWheelEvent);
729 d->pos = pos;
730}
731
732/*!
733 Returns the position of the cursor in scene coordinates when the wheel
734 event occurred.
735
736 \sa pos(), screenPos()
737*/
738QPointF QGraphicsSceneWheelEvent::scenePos() const
739{
740 Q_D(const QGraphicsSceneWheelEvent);
741 return d->scenePos;
742}
743
744/*!
745 \internal
746*/
747void QGraphicsSceneWheelEvent::setScenePos(const QPointF &pos)
748{
749 Q_D(QGraphicsSceneWheelEvent);
750 d->scenePos = pos;
751}
752
753/*!
754 Returns the position of the cursor in screen coordinates when the wheel
755 event occurred.
756
757 \sa pos(), scenePos()
758*/
759QPoint QGraphicsSceneWheelEvent::screenPos() const
760{
761 Q_D(const QGraphicsSceneWheelEvent);
762 return d->screenPos;
763}
764
765/*!
766 \internal
767*/
768void QGraphicsSceneWheelEvent::setScreenPos(const QPoint &pos)
769{
770 Q_D(QGraphicsSceneWheelEvent);
771 d->screenPos = pos;
772}
773
774/*!
775 Returns the mouse buttons that were pressed when the wheel event occurred.
776
777 \sa modifiers()
778*/
779Qt::MouseButtons QGraphicsSceneWheelEvent::buttons() const
780{
781 Q_D(const QGraphicsSceneWheelEvent);
782 return d->buttons;
783}
784
785/*!
786 \internal
787*/
788void QGraphicsSceneWheelEvent::setButtons(Qt::MouseButtons buttons)
789{
790 Q_D(QGraphicsSceneWheelEvent);
791 d->buttons = buttons;
792}
793
794/*!
795 Returns the keyboard modifiers that were active when the wheel event
796 occurred.
797
798 \sa buttons()
799*/
800Qt::KeyboardModifiers QGraphicsSceneWheelEvent::modifiers() const
801{
802 Q_D(const QGraphicsSceneWheelEvent);
803 return d->modifiers;
804}
805
806/*!
807 \internal
808*/
809void QGraphicsSceneWheelEvent::setModifiers(Qt::KeyboardModifiers modifiers)
810{
811 Q_D(QGraphicsSceneWheelEvent);
812 d->modifiers = modifiers;
813}
814
815/*!
816 Returns the distance that the wheel is rotated, in eighths (1/8s)
817 of a degree. A positive value indicates that the wheel was
818 rotated forwards away from the user; a negative value indicates
819 that the wheel was rotated backwards toward the user.
820
821 Most mouse types work in steps of 15 degrees, in which case the delta
822 value is a multiple of 120 (== 15 * 8).
823*/
824int QGraphicsSceneWheelEvent::delta() const
825{
826 Q_D(const QGraphicsSceneWheelEvent);
827 return d->delta;
828}
829
830/*!
831 \internal
832*/
833void QGraphicsSceneWheelEvent::setDelta(int delta)
834{
835 Q_D(QGraphicsSceneWheelEvent);
836 d->delta = delta;
837}
838
839/*!
840 Returns the wheel orientation.
841*/
842Qt::Orientation QGraphicsSceneWheelEvent::orientation() const
843{
844 Q_D(const QGraphicsSceneWheelEvent);
845 return d->orientation;
846}
847
848/*!
849 \internal
850*/
851void QGraphicsSceneWheelEvent::setOrientation(Qt::Orientation orientation)
852{
853 Q_D(QGraphicsSceneWheelEvent);
854 d->orientation = orientation;
855}
856
857/*!
858 \since 6.2
859
860 Returns the scrolling phase of this wheel event.
861
862 \sa QWheelEvent::phase
863*/
864Qt::ScrollPhase QGraphicsSceneWheelEvent::phase() const
865{
866 Q_D(const QGraphicsSceneWheelEvent);
867 return d->scrollPhase;
868}
869
870/*!
871 \internal
872*/
873void QGraphicsSceneWheelEvent::setPhase(Qt::ScrollPhase scrollPhase)
874{
875 Q_D(QGraphicsSceneWheelEvent);
876 d->scrollPhase = scrollPhase;
877}
878
879/*!
880 \since 6.2
881
882 Returns the scrolling distance in pixels on screen. This value is
883 provided on platforms that support high-resolution pixel-based
884 delta values, such as \macos. The value should be used directly
885 to scroll content on screen.
886
887 \sa QWheelEvent::pixelDelta
888*/
889QPoint QGraphicsSceneWheelEvent::pixelDelta() const
890{
891 Q_D(const QGraphicsSceneWheelEvent);
892 return d->pixelDelta;
893}
894
895/*!
896 \internal
897*/
898void QGraphicsSceneWheelEvent::setPixelDelta(QPoint pixelDelta)
899{
900 Q_D(QGraphicsSceneWheelEvent);
901 d->pixelDelta = pixelDelta;
902}
903
904/*!
905 Returns whether the delta values delivered with the event are inverted.
906
907 \since 6.2
908*/
909bool QGraphicsSceneWheelEvent::isInverted() const
910{
911 Q_D(const QGraphicsSceneWheelEvent);
912 return d->inverted;
913}
914
915/*!
916 \internal
917*/
918void QGraphicsSceneWheelEvent::setInverted(bool inverted)
919{
920 Q_D(QGraphicsSceneWheelEvent);
921 d->inverted = inverted;
922}
923
936
937/*!
938 \internal
939
940 Constructs a graphics scene context menu event of the specified \a type.
941*/
942QGraphicsSceneContextMenuEvent::QGraphicsSceneContextMenuEvent(Type type)
943 : QGraphicsSceneEvent(*new QGraphicsSceneContextMenuEventPrivate, type)
944{
945}
946
947/*!
948 Destroys the event.
949*/
950QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent()
951{
952}
953
954/*!
955 Returns the position of the mouse cursor in item coordinates at the moment
956 the context menu was requested.
957
958 \sa scenePos(), screenPos()
959*/
960QPointF QGraphicsSceneContextMenuEvent::pos() const
961{
962 Q_D(const QGraphicsSceneContextMenuEvent);
963 return d->pos;
964}
965
966/*!
967 \fn void QGraphicsSceneContextMenuEvent::setPos(const QPointF &point)
968 \internal
969
970 Sets the position associated with the context menu to the given \a point
971 in item coordinates.
972*/
973void QGraphicsSceneContextMenuEvent::setPos(const QPointF &pos)
974{
975 Q_D(QGraphicsSceneContextMenuEvent);
976 d->pos = pos;
977}
978
979/*!
980 Returns the position of the mouse cursor in scene coordinates at the moment the
981 context menu was requested.
982
983 \sa pos(), screenPos()
984*/
985QPointF QGraphicsSceneContextMenuEvent::scenePos() const
986{
987 Q_D(const QGraphicsSceneContextMenuEvent);
988 return d->scenePos;
989}
990
991/*!
992 \fn void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &point)
993 \internal
994
995 Sets the position associated with the context menu to the given \a point
996 in scene coordinates.
997*/
998void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &pos)
999{
1000 Q_D(QGraphicsSceneContextMenuEvent);
1001 d->scenePos = pos;
1002}
1003
1004/*!
1005 Returns the position of the mouse cursor in screen coordinates at the moment the
1006 context menu was requested.
1007
1008 \sa pos(), scenePos()
1009*/
1010QPoint QGraphicsSceneContextMenuEvent::screenPos() const
1011{
1012 Q_D(const QGraphicsSceneContextMenuEvent);
1013 return d->screenPos;
1014}
1015
1016/*!
1017 \fn void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &point)
1018 \internal
1019
1020 Sets the position associated with the context menu to the given \a point
1021 in screen coordinates.
1022*/
1023void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &pos)
1024{
1025 Q_D(QGraphicsSceneContextMenuEvent);
1026 d->screenPos = pos;
1027}
1028
1029/*!
1030 Returns the keyboard modifiers in use when the context menu was requested.
1031*/
1032Qt::KeyboardModifiers QGraphicsSceneContextMenuEvent::modifiers() const
1033{
1034 Q_D(const QGraphicsSceneContextMenuEvent);
1035 return d->modifiers;
1036}
1037
1038/*!
1039 \internal
1040
1041 Sets the keyboard modifiers associated with the context menu to the \a
1042 modifiers specified.
1043*/
1044void QGraphicsSceneContextMenuEvent::setModifiers(Qt::KeyboardModifiers modifiers)
1045{
1046 Q_D(QGraphicsSceneContextMenuEvent);
1047 d->modifiers = modifiers;
1048}
1049
1050/*!
1051 Returns the reason for the context menu event.
1052
1053 \sa QGraphicsSceneContextMenuEvent::Reason
1054*/
1055QGraphicsSceneContextMenuEvent::Reason QGraphicsSceneContextMenuEvent::reason() const
1056{
1057 Q_D(const QGraphicsSceneContextMenuEvent);
1058 return d->reason;
1059}
1060
1061/*!
1062 \internal
1063 Sets the reason for the context menu event to \a reason.
1064
1065 \sa reason()
1066*/
1067void QGraphicsSceneContextMenuEvent::setReason(Reason reason)
1068{
1069 Q_D(QGraphicsSceneContextMenuEvent);
1070 d->reason = reason;
1071}
1072
1084
1085/*!
1086 \internal
1087
1088 Constructs a graphics scene hover event of the specified \a type.
1089*/
1090QGraphicsSceneHoverEvent::QGraphicsSceneHoverEvent(Type type)
1091 : QGraphicsSceneEvent(*new QGraphicsSceneHoverEventPrivate, type)
1092{
1093}
1094
1095/*!
1096 Destroys the event.
1097*/
1098QGraphicsSceneHoverEvent::~QGraphicsSceneHoverEvent()
1099{
1100}
1101
1102/*!
1103 Returns the position of the mouse cursor in item coordinates at the moment
1104 the hover event was sent.
1105
1106 \sa scenePos(), screenPos()
1107*/
1108QPointF QGraphicsSceneHoverEvent::pos() const
1109{
1110 Q_D(const QGraphicsSceneHoverEvent);
1111 return d->pos;
1112}
1113
1114/*!
1115 \fn void QGraphicsSceneHoverEvent::setPos(const QPointF &point)
1116 \internal
1117
1118 Sets the position associated with the hover event to the given \a point in
1119 item coordinates.
1120*/
1121void QGraphicsSceneHoverEvent::setPos(const QPointF &pos)
1122{
1123 Q_D(QGraphicsSceneHoverEvent);
1124 d->pos = pos;
1125}
1126
1127/*!
1128 Returns the position of the mouse cursor in scene coordinates at the
1129 moment the hover event was sent.
1130
1131 \sa pos(), screenPos()
1132*/
1133QPointF QGraphicsSceneHoverEvent::scenePos() const
1134{
1135 Q_D(const QGraphicsSceneHoverEvent);
1136 return d->scenePos;
1137}
1138
1139/*!
1140 \fn void QGraphicsSceneHoverEvent::setScenePos(const QPointF &point)
1141 \internal
1142
1143 Sets the position associated with the hover event to the given \a point in
1144 scene coordinates.
1145*/
1146void QGraphicsSceneHoverEvent::setScenePos(const QPointF &pos)
1147{
1148 Q_D(QGraphicsSceneHoverEvent);
1149 d->scenePos = pos;
1150}
1151
1152/*!
1153 Returns the position of the mouse cursor in screen coordinates at the
1154 moment the hover event was sent.
1155
1156 \sa pos(), scenePos()
1157*/
1158QPoint QGraphicsSceneHoverEvent::screenPos() const
1159{
1160 Q_D(const QGraphicsSceneHoverEvent);
1161 return d->screenPos;
1162}
1163
1164/*!
1165 \fn void QGraphicsSceneHoverEvent::setScreenPos(const QPoint &point)
1166 \internal
1167
1168 Sets the position associated with the hover event to the given \a point in
1169 screen coordinates.
1170*/
1171void QGraphicsSceneHoverEvent::setScreenPos(const QPoint &pos)
1172{
1173 Q_D(QGraphicsSceneHoverEvent);
1174 d->screenPos = pos;
1175}
1176
1177/*!
1178 \since 4.4
1179
1180 Returns the last recorded mouse cursor position in item coordinates.
1181
1182 \sa lastScenePos(), lastScreenPos(), pos()
1183*/
1184QPointF QGraphicsSceneHoverEvent::lastPos() const
1185{
1186 Q_D(const QGraphicsSceneHoverEvent);
1187 return d->lastPos;
1188}
1189
1190/*!
1191 \internal
1192*/
1193void QGraphicsSceneHoverEvent::setLastPos(const QPointF &pos)
1194{
1195 Q_D(QGraphicsSceneHoverEvent);
1196 d->lastPos = pos;
1197}
1198
1199/*!
1200 \since 4.4
1201
1202 Returns the last recorded, the scene coordinates of the previous mouse or
1203 hover event received by the view, that created the event mouse cursor
1204 position in scene coordinates.
1205
1206 \sa lastPos(), lastScreenPos(), scenePos()
1207*/
1208QPointF QGraphicsSceneHoverEvent::lastScenePos() const
1209{
1210 Q_D(const QGraphicsSceneHoverEvent);
1211 return d->lastScenePos;
1212}
1213
1214/*!
1215 \internal
1216*/
1217void QGraphicsSceneHoverEvent::setLastScenePos(const QPointF &pos)
1218{
1219 Q_D(QGraphicsSceneHoverEvent);
1220 d->lastScenePos = pos;
1221}
1222
1223/*!
1224 \since 4.4
1225
1226 Returns the last recorded mouse cursor position in screen coordinates. The
1227 last recorded position is the position of the previous mouse or hover
1228 event received by the view that created the event.
1229
1230 \sa lastPos(), lastScenePos(), screenPos()
1231*/
1232QPoint QGraphicsSceneHoverEvent::lastScreenPos() const
1233{
1234 Q_D(const QGraphicsSceneHoverEvent);
1235 return d->lastScreenPos;
1236}
1237
1238/*!
1239 \internal
1240*/
1241void QGraphicsSceneHoverEvent::setLastScreenPos(const QPoint &pos)
1242{
1243 Q_D(QGraphicsSceneHoverEvent);
1244 d->lastScreenPos = pos;
1245}
1246
1247/*!
1248 \since 4.4
1249
1250 Returns the keyboard modifiers at the moment the hover event was sent.
1251*/
1252Qt::KeyboardModifiers QGraphicsSceneHoverEvent::modifiers() const
1253{
1254 Q_D(const QGraphicsSceneHoverEvent);
1255 return d->modifiers;
1256}
1257
1258/*!
1259 \fn void QGraphicsSceneHoverEvent::setModifiers(Qt::KeyboardModifiers modifiers)
1260 \internal
1261
1262 Sets the modifiers for the current hover event to \a modifiers.
1263*/
1264void QGraphicsSceneHoverEvent::setModifiers(Qt::KeyboardModifiers modifiers)
1265{
1266 Q_D(QGraphicsSceneHoverEvent);
1267 d->modifiers = modifiers;
1268}
1269
1276
1277/*!
1278 \internal
1279
1280 Constructs a graphics scene help event of the specified \a type.
1281*/
1282QGraphicsSceneHelpEvent::QGraphicsSceneHelpEvent(Type type)
1283 : QGraphicsSceneEvent(*new QGraphicsSceneHelpEventPrivate, type)
1284{
1285}
1286
1287/*!
1288 Destroys the event.
1289*/
1290QGraphicsSceneHelpEvent::~QGraphicsSceneHelpEvent()
1291{
1292}
1293
1294/*!
1295 Returns the position of the mouse cursor in scene coordinates at the
1296 moment the help event was sent.
1297
1298 \sa screenPos()
1299*/
1300QPointF QGraphicsSceneHelpEvent::scenePos() const
1301{
1302 Q_D(const QGraphicsSceneHelpEvent);
1303 return d->scenePos;
1304}
1305
1306/*!
1307 \fn void QGraphicsSceneHelpEvent::setScenePos(const QPointF &point)
1308 \internal
1309
1310 Sets the position associated with the context menu to the given \a point
1311 in scene coordinates.
1312*/
1313void QGraphicsSceneHelpEvent::setScenePos(const QPointF &pos)
1314{
1315 Q_D(QGraphicsSceneHelpEvent);
1316 d->scenePos = pos;
1317}
1318
1319/*!
1320 Returns the position of the mouse cursor in screen coordinates at the
1321 moment the help event was sent.
1322
1323 \sa scenePos()
1324*/
1325QPoint QGraphicsSceneHelpEvent::screenPos() const
1326{
1327 Q_D(const QGraphicsSceneHelpEvent);
1328 return d->screenPos;
1329}
1330
1331/*!
1332 \fn void QGraphicsSceneHelpEvent::setScreenPos(const QPoint &point)
1333 \internal
1334
1335 Sets the position associated with the context menu to the given \a point
1336 in screen coordinates.
1337*/
1338void QGraphicsSceneHelpEvent::setScreenPos(const QPoint &pos)
1339{
1340 Q_D(QGraphicsSceneHelpEvent);
1341 d->screenPos = pos;
1342}
1343
1363
1364/*!
1365 \internal
1366
1367 Constructs a new QGraphicsSceneDragDropEvent of the
1368 specified \a type. The type can be either
1369 QEvent::GraphicsSceneDragEnter, QEvent::GraphicsSceneDragLeave,
1370 QEvent::GraphicsSceneDragMove, or QEvent::GraphicsSceneDrop.
1371*/
1372QGraphicsSceneDragDropEvent::QGraphicsSceneDragDropEvent(Type type)
1373 : QGraphicsSceneEvent(*new QGraphicsSceneDragDropEventPrivate, type)
1374{
1375}
1376
1377/*!
1378 Destroys the object.
1379*/
1380QGraphicsSceneDragDropEvent::~QGraphicsSceneDragDropEvent()
1381{
1382}
1383
1384/*!
1385 Returns the mouse position of the event relative to the
1386 view that sent the event.
1387
1388 \sa QGraphicsView, screenPos(), scenePos()
1389*/
1390QPointF QGraphicsSceneDragDropEvent::pos() const
1391{
1392 Q_D(const QGraphicsSceneDragDropEvent);
1393 return d->pos;
1394}
1395
1396/*!
1397 \internal
1398 Sets the position of the mouse to \a pos; this should be
1399 relative to the widget that generated the event, which normally
1400 is a QGraphicsView.
1401
1402 \sa pos(), setScenePos(), setScreenPos()
1403*/
1404
1405void QGraphicsSceneDragDropEvent::setPos(const QPointF &pos)
1406{
1407 Q_D(QGraphicsSceneDragDropEvent);
1408 d->pos = pos;
1409}
1410
1411/*!
1412 Returns the position of the mouse in scene coordinates.
1413
1414 \sa pos(), screenPos()
1415*/
1416QPointF QGraphicsSceneDragDropEvent::scenePos() const
1417{
1418 Q_D(const QGraphicsSceneDragDropEvent);
1419 return d->scenePos;
1420}
1421
1422/*!
1423 \internal
1424 Sets the scene position of the mouse to \a pos.
1425
1426 \sa scenePos(), setScreenPos(), setPos()
1427*/
1428void QGraphicsSceneDragDropEvent::setScenePos(const QPointF &pos)
1429{
1430 Q_D(QGraphicsSceneDragDropEvent);
1431 d->scenePos = pos;
1432}
1433
1434/*!
1435 Returns the position of the mouse relative to the screen.
1436
1437 \sa pos(), scenePos()
1438*/
1439QPoint QGraphicsSceneDragDropEvent::screenPos() const
1440{
1441 Q_D(const QGraphicsSceneDragDropEvent);
1442 return d->screenPos;
1443}
1444
1445/*!
1446 \internal
1447 Sets the mouse position relative to the screen to \a pos.
1448
1449 \sa screenPos(), setScenePos(), setPos()
1450*/
1451void QGraphicsSceneDragDropEvent::setScreenPos(const QPoint &pos)
1452{
1453 Q_D(QGraphicsSceneDragDropEvent);
1454 d->screenPos = pos;
1455}
1456
1457/*!
1458 Returns a Qt::MouseButtons value indicating which buttons
1459 were pressed on the mouse when this mouse event was
1460 generated.
1461
1462 \sa Qt::MouseButtons
1463*/
1464Qt::MouseButtons QGraphicsSceneDragDropEvent::buttons() const
1465{
1466 Q_D(const QGraphicsSceneDragDropEvent);
1467 return d->buttons;
1468}
1469
1470/*!
1471 \internal
1472 Sets the mouse buttons that were pressed when the event was
1473 created to \a buttons.
1474
1475 \sa Qt::MouseButtons, buttons()
1476*/
1477void QGraphicsSceneDragDropEvent::setButtons(Qt::MouseButtons buttons)
1478{
1479 Q_D(QGraphicsSceneDragDropEvent);
1480 d->buttons = buttons;
1481}
1482
1483/*!
1484 Returns the keyboard modifiers that were pressed when the drag
1485 and drop event was created.
1486
1487 \sa Qt::KeyboardModifiers
1488*/
1489Qt::KeyboardModifiers QGraphicsSceneDragDropEvent::modifiers() const
1490{
1491 Q_D(const QGraphicsSceneDragDropEvent);
1492 return d->modifiers;
1493}
1494
1495/*!
1496 \internal
1497 Sets the keyboard modifiers that were pressed when the event
1498 was created to \a modifiers.
1499
1500 \sa Qt::KeyboardModifiers, modifiers()
1501*/
1502
1503void QGraphicsSceneDragDropEvent::setModifiers(Qt::KeyboardModifiers modifiers)
1504{
1505 Q_D(QGraphicsSceneDragDropEvent);
1506 d->modifiers = modifiers;
1507}
1508
1509/*!
1510 Returns the possible drop actions that the drag and
1511 drop can result in.
1512
1513 \sa Qt::DropActions
1514*/
1515
1516Qt::DropActions QGraphicsSceneDragDropEvent::possibleActions() const
1517{
1518 Q_D(const QGraphicsSceneDragDropEvent);
1519 return d->possibleActions;
1520}
1521
1522/*!
1523 \internal
1524 Sets the possible drop actions that the drag can
1525 result in to \a actions.
1526
1527 \sa Qt::DropActions, possibleActions()
1528*/
1529void QGraphicsSceneDragDropEvent::setPossibleActions(Qt::DropActions actions)
1530{
1531 Q_D(QGraphicsSceneDragDropEvent);
1532 d->possibleActions = actions;
1533}
1534
1535/*!
1536 Returns the drop action that is proposed, i.e., preferred.
1537 The action must be one of the possible actions as defined by
1538 \c possibleActions().
1539
1540 \sa Qt::DropAction, possibleActions()
1541*/
1542
1543Qt::DropAction QGraphicsSceneDragDropEvent::proposedAction() const
1544{
1545 Q_D(const QGraphicsSceneDragDropEvent);
1546 return d->proposedAction;
1547}
1548
1549/*!
1550 \internal
1551 Sets the proposed action to \a action. The proposed action
1552 is a Qt::DropAction that is one of the possible actions as
1553 given by \c possibleActions().
1554
1555 \sa proposedAction(), Qt::DropAction, possibleActions()
1556*/
1557
1558void QGraphicsSceneDragDropEvent::setProposedAction(Qt::DropAction action)
1559{
1560 Q_D(QGraphicsSceneDragDropEvent);
1561 d->proposedAction = action;
1562}
1563
1564/*!
1565 Sets the proposed action as accepted, i.e, the drop action
1566 is set to the proposed action. This is equal to:
1567
1568 \snippet code/src_gui_graphicsview_qgraphicssceneevent.cpp 0
1569
1570 When using this function, one should not call \c accept().
1571
1572 \sa dropAction(), setDropAction(), proposedAction()
1573*/
1574
1575void QGraphicsSceneDragDropEvent::acceptProposedAction()
1576{
1577 Q_D(QGraphicsSceneDragDropEvent);
1578 d->dropAction = d->proposedAction;
1579}
1580
1581/*!
1582 Returns the action that was performed in this drag and drop.
1583 This should be set by the receiver of the drop and is
1584 returned by QDrag::exec().
1585
1586 \sa setDropAction(), acceptProposedAction()
1587*/
1588
1589Qt::DropAction QGraphicsSceneDragDropEvent::dropAction() const
1590{
1591 Q_D(const QGraphicsSceneDragDropEvent);
1592 return d->dropAction;
1593}
1594
1595/*!
1596 This function lets the receiver of the drop set the drop
1597 action that was performed to \a action, which should be one
1598 of the
1599 \l{QGraphicsSceneDragDropEvent::possibleActions()}{possible
1600 actions}. Call \c accept() in stead of \c
1601 acceptProposedAction() if you use this function.
1602
1603 \sa dropAction(), accept(), possibleActions()
1604*/
1605void QGraphicsSceneDragDropEvent::setDropAction(Qt::DropAction action)
1606{
1607 Q_D(QGraphicsSceneDragDropEvent);
1608 d->dropAction = action;
1609}
1610
1611/*!
1612 This function returns the QGraphicsView that created the
1613 QGraphicsSceneDragDropEvent.
1614*/
1615QWidget *QGraphicsSceneDragDropEvent::source() const
1616{
1617 Q_D(const QGraphicsSceneDragDropEvent);
1618 return d->source;
1619}
1620
1621/*!
1622 \internal
1623 This function set the source widget, i.e., the widget that
1624 created the drop event, to \a source.
1625*/
1626void QGraphicsSceneDragDropEvent::setSource(QWidget *source)
1627{
1628 Q_D(QGraphicsSceneDragDropEvent);
1629 d->source = source;
1630}
1631
1632/*!
1633 This function returns the MIME data of the event.
1634*/
1635const QMimeData *QGraphicsSceneDragDropEvent::mimeData() const
1636{
1637 Q_D(const QGraphicsSceneDragDropEvent);
1638 return d->mimeData;
1639}
1640
1641/*!
1642 \internal
1643 This function sets the MIME data for the event.
1644*/
1645void QGraphicsSceneDragDropEvent::setMimeData(const QMimeData *data)
1646{
1647 Q_D(QGraphicsSceneDragDropEvent);
1648 d->mimeData = data;
1649}
1650
1652{
1653 Q_DECLARE_PUBLIC(QGraphicsSceneResizeEvent)
1654public:
1657
1659 QSizeF newSize;
1660};
1661
1662/*!
1663 Constructs a QGraphicsSceneResizeEvent.
1664*/
1665QGraphicsSceneResizeEvent::QGraphicsSceneResizeEvent()
1666 : QGraphicsSceneEvent(*new QGraphicsSceneResizeEventPrivate, QEvent::GraphicsSceneResize)
1667{
1668}
1669
1670/*!
1671 Destroys the QGraphicsSceneResizeEvent.
1672*/
1673QGraphicsSceneResizeEvent::~QGraphicsSceneResizeEvent()
1674{
1675}
1676
1677/*!
1678 Returns the old size (i.e., the size immediately before the widget was
1679 resized).
1680
1681 \sa newSize(), QGraphicsWidget::resize()
1682*/
1683QSizeF QGraphicsSceneResizeEvent::oldSize() const
1684{
1685 Q_D(const QGraphicsSceneResizeEvent);
1686 return d->oldSize;
1687}
1688
1689/*!
1690 \internal
1691*/
1692void QGraphicsSceneResizeEvent::setOldSize(const QSizeF &size)
1693{
1694 Q_D(QGraphicsSceneResizeEvent);
1695 d->oldSize = size;
1696}
1697
1698/*!
1699 Returns the new size (i.e., the current size).
1700
1701 \sa oldSize(), QGraphicsWidget::resize()
1702*/
1703QSizeF QGraphicsSceneResizeEvent::newSize() const
1704{
1705 Q_D(const QGraphicsSceneResizeEvent);
1706 return d->newSize;
1707}
1708
1709/*!
1710 \internal
1711*/
1712void QGraphicsSceneResizeEvent::setNewSize(const QSizeF &size)
1713{
1714 Q_D(QGraphicsSceneResizeEvent);
1715 d->newSize = size;
1716}
1717
1719{
1720 Q_DECLARE_PUBLIC(QGraphicsSceneMoveEvent)
1721public:
1724
1727};
1728
1729/*!
1730 Constructs a QGraphicsSceneMoveEvent.
1731*/
1732QGraphicsSceneMoveEvent::QGraphicsSceneMoveEvent()
1733 : QGraphicsSceneEvent(*new QGraphicsSceneMoveEventPrivate, QEvent::GraphicsSceneMove)
1734{
1735}
1736
1737/*!
1738 Destroys the QGraphicsSceneMoveEvent.
1739*/
1740QGraphicsSceneMoveEvent::~QGraphicsSceneMoveEvent()
1741{
1742}
1743
1744/*!
1745 Returns the old position (i.e., the position immediately before the widget
1746 was moved).
1747
1748 \sa newPos(), QGraphicsItem::setPos()
1749*/
1750QPointF QGraphicsSceneMoveEvent::oldPos() const
1751{
1752 Q_D(const QGraphicsSceneMoveEvent);
1753 return d->oldPos;
1754}
1755
1756/*!
1757 \internal
1758*/
1759void QGraphicsSceneMoveEvent::setOldPos(const QPointF &pos)
1760{
1761 Q_D(QGraphicsSceneMoveEvent);
1762 d->oldPos = pos;
1763}
1764
1765/*!
1766 Returns the new position (i.e., the current position).
1767
1768 \sa oldPos(), QGraphicsItem::setPos()
1769*/
1770QPointF QGraphicsSceneMoveEvent::newPos() const
1771{
1772 Q_D(const QGraphicsSceneMoveEvent);
1773 return d->newPos;
1774}
1775
1776/*!
1777 \internal
1778*/
1779void QGraphicsSceneMoveEvent::setNewPos(const QPointF &pos)
1780{
1781 Q_D(QGraphicsSceneMoveEvent);
1782 d->newPos = pos;
1783}
1784
1785#ifndef QT_NO_DEBUG_STREAM
1786template <class Event>
1787static inline void formatPositions(QDebug &debug, const Event *event)
1788{
1789 debug << ", pos=";
1790 QtDebugUtils::formatQPoint(debug, event->pos());
1791 debug << ", scenePos=";
1792 QtDebugUtils::formatQPoint(debug, event->scenePos());
1793 debug << ", screenPos=";
1794 QtDebugUtils::formatQPoint(debug, event->screenPos());
1795}
1796
1797QDebug operator<<(QDebug debug, const QGraphicsSceneEvent *event)
1798{
1799 QDebugStateSaver saver(debug);
1800 debug.nospace();
1801 if (!event)
1802 return debug << "QGraphicsSceneEvent(0x0)";
1803
1804 const QEvent::Type type = event->type();
1805 switch (type) {
1806 case QEvent::GraphicsSceneMouseMove:
1807 case QEvent::GraphicsSceneMousePress:
1808 case QEvent::GraphicsSceneMouseRelease:
1809 case QEvent::GraphicsSceneMouseDoubleClick: {
1810 const QGraphicsSceneMouseEvent *me = static_cast<const QGraphicsSceneMouseEvent *>(event);
1811 const Qt::MouseButton button = me->button();
1812 const Qt::MouseButtons buttons = me->buttons();
1813 debug << "QGraphicsSceneMouseEvent(";
1814 QtDebugUtils::formatQEnum(debug, type);
1815 if (type != QEvent::GraphicsSceneMouseMove) {
1816 debug << ", ";
1817 QtDebugUtils::formatQEnum(debug, button);
1818 }
1819 if (buttons && button != buttons) {
1820 debug << ", buttons=";
1821 QtDebugUtils::formatQFlags(debug, buttons);
1822 }
1823 QtDebugUtils::formatNonNullQFlags(debug, ", ", me->modifiers());
1824 formatPositions(debug, me);
1825 QtDebugUtils::formatNonNullQEnum(debug, ", ", me->source());
1826 QtDebugUtils::formatNonNullQFlags(debug, ", flags=", me->flags());
1827 debug << ')';
1828 }
1829 break;
1830 case QEvent::GraphicsSceneContextMenu: {
1831 const QGraphicsSceneContextMenuEvent *ce = static_cast<const QGraphicsSceneContextMenuEvent *>(event);
1832 debug << "QGraphicsSceneContextMenuEvent(reason=" << ce->reason();
1833 QtDebugUtils::formatNonNullQFlags(debug, ", ", ce->modifiers());
1834 formatPositions(debug, ce);
1835 debug << ')';
1836 }
1837 break;
1838 case QEvent::GraphicsSceneHoverEnter:
1839 case QEvent::GraphicsSceneHoverMove:
1840 case QEvent::GraphicsSceneHoverLeave:
1841 debug << "QGraphicsSceneHoverEvent(";
1842 formatPositions(debug, static_cast<const QGraphicsSceneHoverEvent *>(event));
1843 debug << ')';
1844 break;
1845 case QEvent::GraphicsSceneHelp:
1846 break;
1847 case QEvent::GraphicsSceneDragEnter:
1848 case QEvent::GraphicsSceneDragMove:
1849 case QEvent::GraphicsSceneDragLeave:
1850 case QEvent::GraphicsSceneDrop: {
1851 const QGraphicsSceneDragDropEvent *de = static_cast<const QGraphicsSceneDragDropEvent *>(event);
1852 debug << "QGraphicsSceneDragDropEvent(proposedAction=";
1853 QtDebugUtils::formatQEnum(debug, de->proposedAction());
1854 debug << ", possibleActions=";
1855 QtDebugUtils::formatQFlags(debug, de->possibleActions());
1856 debug << ", source=" << de->source();
1857 QtDebugUtils::formatNonNullQFlags(debug, ", buttons=", de->buttons());
1858 QtDebugUtils::formatNonNullQFlags(debug, ", ", de->modifiers());
1859 formatPositions(debug, de);
1860 }
1861 break;
1862 case QEvent::GraphicsSceneWheel: {
1863 const QGraphicsSceneWheelEvent *we = static_cast<const QGraphicsSceneWheelEvent *>(event);
1864 debug << "QGraphicsSceneWheelEvent(";
1865 QtDebugUtils::formatNonNullQFlags(debug, ", buttons=", we->buttons());
1866 QtDebugUtils::formatNonNullQFlags(debug, ", ", we->modifiers());
1867 formatPositions(debug, we);
1868 debug << ')';
1869 }
1870 break;
1871 default:
1872 break;
1873 }
1874 return debug;
1875}
1876#endif // !QT_NO_DEBUG_STREAM
1877
1878QT_END_NAMESPACE
QGraphicsSceneContextMenuEvent::Reason reason
QMap< Qt::MouseButton, QPoint > buttonDownScreenPos
QMap< Qt::MouseButton, QPointF > buttonDownPos
QMap< Qt::MouseButton, QPointF > buttonDownScenePos
friend class QWidget
Definition qpainter.h:431
\inmodule QtCore\reentrant
Definition qpoint.h:231
static void formatPositions(QDebug &debug, const Event *event)
QDebug operator<<(QDebug debug, const QGraphicsSceneEvent *event)