Qt 4.8
qgraphicssceneevent.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
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.
16 **
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.
24 **
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.
28 **
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.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
283 #include "qgraphicssceneevent.h"
284 
285 #ifndef QT_NO_GRAPHICSVIEW
286 
287 #ifndef QT_NO_DEBUG
288 #include <QtCore/qdebug.h>
289 #endif
290 #include <QtCore/qmap.h>
291 #include <QtCore/qpoint.h>
292 #include <QtCore/qsize.h>
293 #include <QtCore/qstring.h>
294 #include "qgraphicsview.h"
295 #include "qgraphicsitem.h"
296 #include <QtGui/qgesture.h>
297 #include <private/qevent_p.h>
298 
300 
302 {
303 public:
305  : widget(0),
306  q_ptr(0)
307  { }
308 
310  { }
311 
314 };
315 
325  : QEvent(type), d_ptr(new QGraphicsSceneEventPrivate)
326 {
327  d_ptr->q_ptr = this;
328 }
329 
339  : QEvent(type), d_ptr(&dd)
340 {
341  d_ptr->q_ptr = this;
342 }
343 
348 {
349 }
350 
356 {
357  return d_ptr->widget;
358 }
359 
371 {
372  d_ptr->widget = widget;
373 }
374 
376 {
378 public:
380  : button(Qt::NoButton),
381  buttons(0), modifiers(0)
382  { }
383 
394  Qt::MouseButtons buttons;
395  Qt::KeyboardModifiers modifiers;
396 };
397 
408 {
409 }
410 
415 {
416 }
417 
424 {
426  return d->pos;
427 }
428 
433 {
435  d->pos = pos;
436 }
437 
444 {
446  return d->scenePos;
447 }
448 
453 {
455  d->scenePos = pos;
456 }
457 
464 {
466  return d->screenPos;
467 }
468 
473 {
475  d->screenPos = pos;
476 }
477 
485 {
487  return d->buttonDownPos.value(button);
488 }
489 
494 {
496  d->buttonDownPos.insert(button, pos);
497 }
498 
506 {
508  return d->buttonDownScenePos.value(button);
509 }
510 
515 {
517  d->buttonDownScenePos.insert(button, pos);
518 }
519 
527 {
529  return d->buttonDownScreenPos.value(button);
530 }
531 
536 {
538  d->buttonDownScreenPos.insert(button, pos);
539 }
540 
548 {
550  return d->lastPos;
551 }
552 
557 {
559  d->lastPos = pos;
560 }
561 
571 {
573  return d->lastScenePos;
574 }
575 
580 {
582  d->lastScenePos = pos;
583 }
584 
594 {
596  return d->lastScreenPos;
597 }
598 
603 {
605  d->lastScreenPos = pos;
606 }
607 
614 Qt::MouseButtons QGraphicsSceneMouseEvent::buttons() const
615 {
617  return d->buttons;
618 }
619 
624 {
626  d->buttons = buttons;
627 }
628 
635 {
637  return d->button;
638 }
639 
644 {
646  d->button = button;
647 }
648 
655 Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers() const
656 {
658  return d->modifiers;
659 }
660 
665 {
667  d->modifiers = modifiers;
668 }
669 
671 {
673 public:
675  : buttons(0), modifiers(0), delta(0), orientation(Qt::Horizontal)
676  { }
677 
681  Qt::MouseButtons buttons;
682  Qt::KeyboardModifiers modifiers;
683  int delta;
685 };
686 
698 {
699 }
700 
705 {
706 }
707 
715 {
717  return d->pos;
718 }
719 
724 {
726  d->pos = pos;
727 }
728 
736 {
738  return d->scenePos;
739 }
740 
745 {
747  d->scenePos = pos;
748 }
749 
757 {
759  return d->screenPos;
760 }
761 
766 {
768  d->screenPos = pos;
769 }
770 
776 Qt::MouseButtons QGraphicsSceneWheelEvent::buttons() const
777 {
779  return d->buttons;
780 }
781 
786 {
788  d->buttons = buttons;
789 }
790 
797 Qt::KeyboardModifiers QGraphicsSceneWheelEvent::modifiers() const
798 {
800  return d->modifiers;
801 }
802 
807 {
809  d->modifiers = modifiers;
810 }
811 
822 {
824  return d->delta;
825 }
826 
831 {
833  d->delta = delta;
834 }
835 
840 {
842  return d->orientation;
843 }
844 
849 {
851  d->orientation = orientation;
852 }
853 
855 {
857  public:
859  : modifiers(0), reason(QGraphicsSceneContextMenuEvent::Other)
860  { }
861 
865  Qt::KeyboardModifiers modifiers;
867 };
868 
879 {
880 }
881 
886 {
887 }
888 
896 {
898  return d->pos;
899 }
900 
912 {
914  d->pos = pos;
915 }
916 
924 {
926  return d->scenePos;
927 }
928 
940 {
942  d->scenePos = pos;
943 }
944 
952 {
954  return d->screenPos;
955 }
956 
968 {
970  d->screenPos = pos;
971 }
972 
976 Qt::KeyboardModifiers QGraphicsSceneContextMenuEvent::modifiers() const
977 {
979  return d->modifiers;
980 }
981 
992 {
994  d->modifiers = modifiers;
995 }
996 
1003 {
1005  return d->reason;
1006 }
1007 
1018 {
1020  d->reason = reason;
1021 }
1022 
1024 {
1025 public:
1032  Qt::KeyboardModifiers modifiers;
1033 };
1034 
1045 {
1046 }
1047 
1052 {
1053 }
1054 
1062 {
1064  return d->pos;
1065 }
1066 
1078 {
1080  d->pos = pos;
1081 }
1082 
1090 {
1092  return d->scenePos;
1093 }
1094 
1106 {
1108  d->scenePos = pos;
1109 }
1110 
1118 {
1120  return d->screenPos;
1121 }
1122 
1134 {
1136  d->screenPos = pos;
1137 }
1138 
1150 {
1152  return d->lastPos;
1153 }
1154 
1159 {
1161  d->lastPos = pos;
1162 }
1163 
1177 {
1179  return d->lastScenePos;
1180 }
1181 
1186 {
1188  d->lastScenePos = pos;
1189 }
1190 
1204 {
1206  return d->lastScreenPos;
1207 }
1208 
1213 {
1215  d->lastScreenPos = pos;
1216 }
1217 
1226 Qt::KeyboardModifiers QGraphicsSceneHoverEvent::modifiers() const
1227 {
1229  return d->modifiers;
1230 }
1231 
1242 {
1244  d->modifiers = modifiers;
1245 }
1246 
1248 {
1249 public:
1252 };
1253 
1264 {
1265 }
1266 
1271 {
1272 }
1273 
1281 {
1283  return d->scenePos;
1284 }
1285 
1297 {
1299  d->scenePos = pos;
1300 }
1301 
1309 {
1311  return d->screenPos;
1312 }
1313 
1325 {
1327  d->screenPos = pos;
1328 }
1329 
1331 {
1333 public:
1335  : source(0), mimeData(0)
1336  { }
1337 
1341  Qt::MouseButtons buttons;
1342  Qt::KeyboardModifiers modifiers;
1343  Qt::DropActions possibleActions;
1348 };
1349 
1363 {
1364 }
1365 
1370 {
1371 }
1372 
1380 {
1382  return d->pos;
1383 }
1384 
1398 {
1400  d->pos = pos;
1401 }
1402 
1409 {
1411  return d->scenePos;
1412 }
1413 
1424 {
1426  d->scenePos = pos;
1427 }
1428 
1435 {
1437  return d->screenPos;
1438 }
1439 
1450 {
1452  d->screenPos = pos;
1453 }
1454 
1463 {
1465  return d->buttons;
1466 }
1467 
1479 {
1481  d->buttons = buttons;
1482 }
1483 
1490 Qt::KeyboardModifiers QGraphicsSceneDragDropEvent::modifiers() const
1491 {
1493  return d->modifiers;
1494 }
1495 
1508 {
1510  d->modifiers = modifiers;
1511 }
1512 
1521 {
1523  return d->possibleActions;
1524 }
1525 
1537 {
1539  d->possibleActions = actions;
1540 }
1541 
1551 {
1553  return d->proposedAction;
1554 }
1555 
1569 {
1571  d->proposedAction = action;
1572 }
1573 
1586 {
1588  d->dropAction = d->proposedAction;
1589 }
1590 
1600 {
1602  return d->dropAction;
1603 }
1604 
1615 {
1617  d->dropAction = action;
1618 }
1619 
1625 {
1627  return d->source;
1628 }
1629 
1639 {
1641  d->source = source;
1642 }
1643 
1648 {
1650  return d->mimeData;
1651 }
1652 
1661 {
1663  d->mimeData = data;
1664 }
1665 
1667 {
1669 public:
1671  { }
1672 
1675 };
1676 
1682 {
1683 }
1684 
1689 {
1690 }
1691 
1699 {
1701  return d->oldSize;
1702 }
1703 
1708 {
1710  d->oldSize = size;
1711 }
1712 
1719 {
1721  return d->newSize;
1722 }
1723 
1728 {
1730  d->newSize = size;
1731 }
1732 
1734 {
1736 public:
1738  { }
1739 
1742 };
1743 
1749 {
1750 }
1751 
1756 {
1757 }
1758 
1766 {
1768  return d->oldPos;
1769 }
1770 
1775 {
1777  d->oldPos = pos;
1778 }
1779 
1786 {
1788  return d->newPos;
1789 }
1790 
1795 {
1797  d->newPos = pos;
1798 }
1799 
1801 
1802 #endif // QT_NO_GRAPHICSVIEW
Qt::DropAction dropAction() const
Returns the action that was performed in this drag and drop.
const QMimeData * mimeData() const
This function returns the MIME data of the event.
void setModifiers(Qt::KeyboardModifiers modifiers)
void setSource(QWidget *source)
This function set the source widget, i.
void setScenePos(const QPointF &pos)
Sets the scene position of the mouse to pos.
QPointF scenePos() const
Returns the position of the mouse cursor in scene coordinates at the moment the help event was sent...
QPoint screenPos() const
Returns the mouse cursor position in screen coordinates.
int type
Definition: qmetatype.cpp:239
void setNewSize(const QSizeF &size)
~QGraphicsSceneContextMenuEvent()
Destroys the event.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QScopedPointer< QGraphicsSceneEventPrivate > d_ptr
QGraphicsSceneHelpEvent(Type type=None)
Constructs a graphics scene help event of the specified type.
void setModifiers(Qt::KeyboardModifiers modifiers)
void setScenePos(const QPointF &pos)
Sets the position associated with the context menu to the given point in scene coordinates.
void setLastPos(const QPointF &pos)
QGraphicsSceneDragDropEvent(Type type=None)
Constructs a new QGraphicsSceneDragDropEvent of the specified type.
QSizeF oldSize() const
Returns the old size (i.e., the size immediately before the widget was resized).
~QGraphicsSceneWheelEvent()
Destroys the QGraphicsSceneWheelEvent.
void setButtonDownScenePos(Qt::MouseButton button, const QPointF &pos)
void setScreenPos(const QPoint &pos)
void setMimeData(const QMimeData *data)
This function sets the MIME data for the event.
~QGraphicsSceneResizeEvent()
Destroys the QGraphicsSceneResizeEvent.
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the hover event was sent...
void setScenePos(const QPointF &pos)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
QGraphicsSceneContextMenuEvent::Reason reason
static Qt::MouseButtons buttons
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers in use when the context menu was requested.
QGraphicsSceneEvent(Type type)
Constructs a generic graphics scene event of the specified type.
Qt::MouseButton button() const
Returns the mouse button (if any) that caused the event.
~QGraphicsSceneHelpEvent()
Destroys the event.
Qt::MouseButtons buttons() const
Returns a Qt::MouseButtons value indicating which buttons were pressed on the mouse when this mouse e...
void setButtonDownPos(Qt::MouseButton button, const QPointF &pos)
QPointF scenePos() const
Returns the position of the mouse cursor in scene coordinates at the moment the the context menu was ...
QWidget * widget() const
Returns the widget where the event originated, or 0 if the event originates from another application...
~QGraphicsSceneMouseEvent()
Destroys the event.
The QGraphicsSceneResizeEvent class provides events for widget resizing in the graphics view framewor...
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers that were pressed when the drag and drop event was created...
void setButtons(Qt::MouseButtons buttons)
void setOldSize(const QSizeF &size)
void setScenePos(const QPointF &pos)
QPointF newPos() const
Returns the new position (i.e., the current position).
void setWidget(QWidget *widget)
Sets the widget related to this event.
The QGraphicsSceneMoveEvent class provides events for widget moving in the graphics view framework...
#define Q_D(Class)
Definition: qglobal.h:2482
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
void setButtons(Qt::MouseButtons buttons)
QPointF pos() const
Returns the position of the cursor in item coordinates when the wheel event occurred.
QPointF buttonDownScenePos(Qt::MouseButton button) const
Returns the mouse cursor position in scene coordinates where the specified button was clicked...
QPointF lastScenePos() const
Returns the last recorded, the scene coordinates of the previous mouse or hover event received by the...
QWidget * source() const
This function returns the QGraphicsView that created the QGraphicsSceneDragDropEvent.
void setPos(const QPointF &pos)
Sets the position associated with the context menu to the given point in item coordinates.
QPointF lastScenePos() const
Returns the last recorded mouse cursor position in scene coordinates.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
~QGraphicsSceneEvent()
Destroys the event.
void setPos(const QPointF &pos)
QGraphicsSceneMouseEvent(Type type=None)
Constructs a generic graphics scene mouse event of the specified type.
void setModifiers(Qt::KeyboardModifiers modifiers)
Sets the keyboard modifiers associated with the context menu to the modifiers specified.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers at the moment the hover event was sent.
Qt::MouseButtons buttons() const
Returns the mouse buttons that were pressed when the wheel event occurred.
void setPossibleActions(Qt::DropActions actions)
Sets the possible drop actions that the drag can result in to actions.
QMap< Qt::MouseButton, QPoint > buttonDownScreenPos
void setScreenPos(const QPoint &pos)
Sets the position associated with the context menu to the given point in screen coordinates.
void setDropAction(Qt::DropAction action)
This function lets the receiver of the drop set the drop action that was performed to action...
void setModifiers(Qt::KeyboardModifiers modifiers)
Sets the modifiers for the current hover event to modifiers.
void setPos(const QPointF &pos)
Sets the position of the mouse to pos; this should be relative to the widget that generated the event...
void setOldPos(const QPointF &pos)
QPoint screenPos() const
Returns the position of the cursor in screen coordinates when the wheel event occurred.
void setPos(const QPointF &pos)
QPointF pos() const
Returns the position of the mouse cursor in item coordinates at the moment the context menu was reque...
QMap< Qt::MouseButton, QPointF > buttonDownScenePos
QPoint screenPos() const
Returns the position of the mouse relative to the screen.
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the the context menu was...
static const char * data(const QByteArray &arr)
DropAction
Definition: qnamespace.h:1597
The QGraphicsSceneEvent class provides a base class for all graphics view related events...
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
QGraphicsSceneWheelEvent(Type type=None)
Constructs a QGraphicsSceneWheelEvent of type type, which is always QEvent::GraphicsSceneWheel.
void setLastScenePos(const QPointF &pos)
void acceptProposedAction()
Sets the proposed action as accepted, i.e, the drop action is set to the proposed action...
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the help event was sent...
QGraphicsSceneContextMenuEvent(Type type=None)
Constructs a graphics scene context menu event of the specified type.
QPointF oldPos() const
Returns the old position (i.e., the position immediately before the widget was moved).
QGraphicsSceneResizeEvent()
Constructs a QGraphicsSceneResizeEvent.
Qt::DropAction proposedAction() const
Returns the drop action that is proposed, i.e., preferred.
QEventPrivate * d
Definition: qcoreevent.h:315
void setReason(Reason reason)
Sets the reason for the context menu event to reason.
QPointF lastPos() const
Returns the last recorded mouse cursor position in item coordinates.
Qt::DropActions possibleActions() const
Returns the possible drop actions that the drag and drop can result in.
~QGraphicsSceneMoveEvent()
Destroys the QGraphicsSceneMoveEvent.
The QGraphicsSceneHelpEvent class provides events when a tooltip is requested.
QGraphicsSceneMoveEvent()
Constructs a QGraphicsSceneMoveEvent.
void setLastScreenPos(const QPoint &pos)
QPointF scenePos() const
Returns the position of the cursor in scene coordinates when the wheel event occurred.
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
int delta() const
Returns the distance that the wheel is rotated, in eighths (1/8s) of a degree.
QSizeF newSize() const
Returns the new size (i.e., the current size).
void setScreenPos(const QPoint &pos)
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
QPoint lastScreenPos() const
Returns the last recorded mouse cursor position in screen coordinates.
QPointF scenePos() const
Returns the mouse cursor position in scene coordinates.
void setLastScenePos(const QPointF &pos)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
~QGraphicsSceneDragDropEvent()
Destroys the object.
void setModifiers(Qt::KeyboardModifiers modifiers)
Sets the keyboard modifiers that were pressed when the event was created to modifiers.
void setScreenPos(const QPoint &pos)
Sets the position associated with the hover event to the given point in screen coordinates.
void setScenePos(const QPointF &pos)
Sets the position associated with the context menu to the given point in scene coordinates.
QPointF pos() const
Returns the position of the mouse cursor in item coordinates at the moment the hover event was sent...
Definition: qnamespace.h:54
QPoint buttonDownScreenPos(Qt::MouseButton button) const
Returns the mouse cursor position in screen coordinates where the specified button was clicked...
void setButtons(Qt::MouseButtons buttons)
Sets the mouse buttons that were pressed when the event was created to buttons.
QGraphicsSceneHoverEvent(Type type=None)
Constructs a graphics scene hover event of the specified type.
void setProposedAction(Qt::DropAction action)
Sets the proposed action to action.
QPointF scenePos() const
Returns the position of the mouse in scene coordinates.
void setPos(const QPointF &pos)
Sets the position associated with the hover event to the given point in item coordinates.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers that were active when the wheel event occurred.
QPointF scenePos() const
Returns the position of the mouse cursor in scene coordinates at the moment the hover event was sent...
QPointF pos() const
Returns the mouse cursor position in item coordinates.
QPointF buttonDownPos(Qt::MouseButton button) const
Returns the mouse cursor position in item coordinates where the specified button was clicked...
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers in use at the time the event was sent.
void setScreenPos(const QPoint &pos)
Sets the position associated with the context menu to the given point in screen coordinates.
QMap< Qt::MouseButton, QPointF > buttonDownPos
QPoint lastScreenPos() const
Returns the last recorded mouse cursor position in screen coordinates.
The QGraphicsSceneWheelEvent class provides wheel events in the graphics view framework.
void setLastScreenPos(const QPoint &pos)
Qt::Orientation orientation() const
Returns the wheel orientation.
void setButtonDownScreenPos(Qt::MouseButton button, const QPoint &pos)
Orientation
Definition: qnamespace.h:174
Reason
This enum describes the reason why the context event was sent.
void setButton(Qt::MouseButton button)
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
void setOrientation(Qt::Orientation orientation)
void setScreenPos(const QPoint &pos)
Sets the mouse position relative to the screen to pos.
~QGraphicsSceneHoverEvent()
Destroys the event.
void setNewPos(const QPointF &pos)
QPointF lastPos() const
Returns the last recorded mouse cursor position in item coordinates.
void setLastPos(const QPointF &pos)
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent...
void setScenePos(const QPointF &pos)
Sets the position associated with the hover event to the given point in scene coordinates.
QPointF pos() const
Returns the mouse position of the event relative to the view that sent the event. ...
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
Reason reason() const
Returns the reason for the context menu event.
MouseButton
Definition: qnamespace.h:150
The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework...