Qt 4.8
qdeclarativemousearea.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 QtDeclarative 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 
42 #include "private/qdeclarativemousearea_p.h"
43 #include "private/qdeclarativemousearea_p_p.h"
44 
45 #include "private/qdeclarativeevents_p_p.h"
46 
47 #include <QGraphicsSceneMouseEvent>
48 
49 #include <float.h>
50 
52 static const int PressAndHoldDelay = 800;
53 
55 : QObject(parent), _target(0), _axis(XandYAxis), _xmin(-FLT_MAX), _xmax(FLT_MAX), _ymin(-FLT_MAX), _ymax(FLT_MAX),
56 _active(false), _filterChildren(false)
57 {
58 }
59 
61 {
62 }
63 
65 {
66  return _target;
67 }
68 
70 {
71  if (_target == t)
72  return;
73  _target = t;
75 }
76 
78 {
79  if (!_target)
80  return;
81  _target = 0;
83 }
84 
86 {
87  return _axis;
88 }
89 
91 {
92  if (_axis == a)
93  return;
94  _axis = a;
95  emit axisChanged();
96 }
97 
99 {
100  return _xmin;
101 }
102 
104 {
105  if (_xmin == m)
106  return;
107  _xmin = m;
109 }
110 
112 {
113  return _xmax;
114 }
115 
117 {
118  if (_xmax == m)
119  return;
120  _xmax = m;
122 }
123 
125 {
126  return _ymin;
127 }
128 
130 {
131  if (_ymin == m)
132  return;
133  _ymin = m;
135 }
136 
138 {
139  return _ymax;
140 }
141 
143 {
144  if (_ymax == m)
145  return;
146  _ymax = m;
148 }
149 
150 bool QDeclarativeDrag::active() const
151 {
152  return _active;
153 }
154 
156 {
157  if (_active == drag)
158  return;
159  _active = drag;
161 }
162 
164 {
165  return _filterChildren;
166 }
167 
169 {
170  if (_filterChildren == filter)
171  return;
174 }
175 
177 {
178  delete drag;
179 }
180 
389 {
391  d->init();
392 }
393 
395 {
396 }
397 
421 {
422  Q_D(const QDeclarativeMouseArea);
423  return d->lastPos.x();
424 }
425 
427 {
428  Q_D(const QDeclarativeMouseArea);
429  return d->lastPos.y();
430 }
431 
442 {
443  Q_D(const QDeclarativeMouseArea);
444  return d->absorb;
445 }
446 
448 {
450  if (a != d->absorb) {
451  d->absorb = a;
453  }
454 }
455 
477 {
478  Q_D(const QDeclarativeMouseArea);
479  return d->preventStealing;
480 }
481 
483 {
485  if (prevent != d->preventStealing) {
486  d->preventStealing = prevent;
487  setKeepMouseGrab(d->preventStealing && d->absorb);
489  }
490 }
491 
512 Qt::MouseButtons QDeclarativeMouseArea::pressedButtons() const
513 {
514  Q_D(const QDeclarativeMouseArea);
515  return d->lastButtons;
516 }
517 
519 {
521  d->moved = false;
522  d->stealMouse = d->preventStealing;
523  if (!d->absorb)
525  else {
526  d->longPress = false;
527  d->saveEvent(event);
528  if (d->drag)
529  d->drag->setActive(false);
530  setHovered(true);
531  d->startScene = event->scenePos();
532  // we should only start timer if pressAndHold is connected to.
533  if (d->isPressAndHoldConnected())
534  d->pressAndHoldTimer.start(PressAndHoldDelay, this);
535  setKeepMouseGrab(d->stealMouse);
536  event->setAccepted(setPressed(true));
537  }
538 }
539 
541 {
543  if (!d->absorb) {
545  return;
546  }
547 
548  d->saveEvent(event);
549 
550  // ### we should skip this if these signals aren't used
551  // ### can GV handle this for us?
552  bool contains = boundingRect().contains(d->lastPos);
553  if (d->hovered && !contains)
554  setHovered(false);
555  else if (!d->hovered && contains)
556  setHovered(true);
557 
558  if (d->drag && d->drag->target()) {
559  if (!d->moved) {
560  d->startX = drag()->target()->x();
561  d->startY = drag()->target()->y();
562  }
563 
564  QPointF startLocalPos;
565  QPointF curLocalPos;
566  if (drag()->target()->parentItem()) {
567  startLocalPos = drag()->target()->parentItem()->mapFromScene(d->startScene);
568  curLocalPos = drag()->target()->parentItem()->mapFromScene(event->scenePos());
569  } else {
570  startLocalPos = d->startScene;
571  curLocalPos = event->scenePos();
572  }
573 
574  if (keepMouseGrab() && d->stealMouse)
575  d->drag->setActive(true);
576 
577  bool dragX = drag()->axis() & QDeclarativeDrag::XAxis;
578  bool dragY = drag()->axis() & QDeclarativeDrag::YAxis;
579 
580  const qreal x = dragX
581  ? qBound(d->drag->xmin(), d->startX + curLocalPos.x() - startLocalPos.x(), d->drag->xmax())
582  : d->startX;
583  const qreal y = dragY
584  ? qBound(d->drag->ymin(), d->startY + curLocalPos.y() - startLocalPos.y(), d->drag->ymax())
585  : d->startY;
586 
587  if (d->drag->active()) {
588  if (dragX && dragY)
589  d->drag->target()->setPos(x, y);
590  else if (dragX)
591  d->drag->target()->setX(x);
592  else if (dragY)
593  d->drag->target()->setY(y);
594  }
595 
596  if (!keepMouseGrab()) {
597  const int dragThreshold = QApplication::startDragDistance();
598 
599  if (qAbs(x - d->startX) > dragThreshold || qAbs(y - d->startY) > dragThreshold) {
600  setKeepMouseGrab(true);
601  d->stealMouse = true;
602  }
603  }
604 
605  d->moved = true;
606  }
607  QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
609  me.setX(d->lastPos.x());
610  me.setY(d->lastPos.y());
611  emit positionChanged(&me);
612 }
613 
614 
616 {
618  d->stealMouse = false;
619  if (!d->absorb) {
621  } else {
622  d->saveEvent(event);
623  setPressed(false);
624  if (d->drag)
625  d->drag->setActive(false);
626  // If we don't accept hover, we need to reset containsMouse.
627  if (!acceptHoverEvents())
628  setHovered(false);
629  QGraphicsScene *s = scene();
630  if (s && s->mouseGrabberItem() == this)
631  ungrabMouse();
632  setKeepMouseGrab(false);
633  }
634  d->doubleClick = false;
635 }
636 
638 {
640  if (!d->absorb) {
642  } else {
643  if (d->isDoubleClickConnected())
644  d->doubleClick = true;
645  d->saveEvent(event);
646  QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false);
647  me.setAccepted(d->isDoubleClickConnected());
648  emit this->doubleClicked(&me);
650  }
651 }
652 
654 {
656  if (!d->absorb)
658  else {
659  d->lastPos = event->pos();
660  setHovered(true);
661  QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false);
663  }
664 }
665 
667 {
669  if (!d->absorb) {
671  } else {
672  d->lastPos = event->pos();
673  QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false);
675  me.setX(d->lastPos.x());
676  me.setY(d->lastPos.y());
677  emit positionChanged(&me);
678  }
679 }
680 
682 {
684  if (!d->absorb)
686  else
687  setHovered(false);
688 }
689 
690 #ifndef QT_NO_CONTEXTMENU
692 {
693  bool acceptsContextMenuButton;
694 #if defined(Q_OS_SYMBIAN)
695  // In Symbian a Long Tap on the screen will trigger. See QSymbianControl::HandleLongTapEventL().
696  acceptsContextMenuButton = acceptedButtons() & Qt::LeftButton;
697 #elif defined(Q_WS_WINCE)
698  // ### WinCE can trigger context menu event with a gesture in the left button or a
699  // click with the right button. Since we have no way here to differentiate them when
700  // event happens, accepting either of the them will block the event.
701  acceptsContextMenuButton = acceptedButtons() & (Qt::LeftButton | Qt::RightButton);
702 #else
703  acceptsContextMenuButton = acceptedButtons() & Qt::RightButton;
704 #endif
705 
707  && acceptsContextMenuButton) {
708  // Do not let the context menu event propagate to items behind.
709  return;
710  }
711 
713 }
714 #endif // QT_NO_CONTEXTMENU
715 
717 {
718  bool rv = QDeclarativeItem::sceneEvent(event);
719  if (event->type() == QEvent::UngrabMouse) {
721  if (d->pressed) {
722  // if our mouse grab has been removed (probably by Flickable), fix our
723  // state
724  d->pressed = false;
725  d->stealMouse = false;
726  setKeepMouseGrab(false);
727  emit canceled();
729  if (d->hovered) {
730  d->hovered = false;
732  }
733  }
734  }
735  return rv;
736 }
737 
739 {
742  QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect();
743 
744  QGraphicsScene *s = scene();
746  bool stealThisEvent = d->stealMouse;
747  if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
748  mouseEvent.setAccepted(false);
749  for (int i = 0x1; i <= 0x10; i <<= 1) {
750  if (event->buttons() & i) {
751  Qt::MouseButton button = Qt::MouseButton(i);
752  mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button)));
753  }
754  }
755  mouseEvent.setScenePos(event->scenePos());
756  mouseEvent.setLastScenePos(event->lastScenePos());
757  mouseEvent.setPos(mapFromScene(event->scenePos()));
758  mouseEvent.setLastPos(mapFromScene(event->lastScenePos()));
759 
760  switch(mouseEvent.type()) {
763  break;
766  break;
769  break;
770  default:
771  break;
772  }
774  if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
775  grabMouse();
776 
777  return stealThisEvent;
778  }
780  if (d->pressed) {
781  d->pressed = false;
782  d->stealMouse = false;
783  if (s && s->mouseGrabberItem() == this)
784  ungrabMouse();
785  emit canceled();
787  if (d->hovered) {
788  d->hovered = false;
790  }
791  }
792  }
793  return false;
794 }
795 
797 {
799  if (!d->absorb || !isVisible() || !d->drag || !d->drag->filterChildren())
801  switch (e->type()) {
805  return sendMouseEvent(static_cast<QGraphicsSceneMouseEvent *>(e));
806  default:
807  break;
808  }
809 
811 }
812 
814 {
816  if (event->timerId() == d->pressAndHoldTimer.timerId()) {
817  d->pressAndHoldTimer.stop();
818  bool dragged = d->drag && d->drag->active();
819  if (d->pressed && dragged == false && d->hovered == true) {
820  d->longPress = true;
821  QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
822  emit pressAndHold(&me);
823  }
824  }
825 }
826 
828  const QRectF &oldGeometry)
829 {
831  QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
832 
833  if (d->lastScenePos.isNull)
834  d->lastScenePos = mapToScene(d->lastPos);
835  else if (newGeometry.x() != oldGeometry.x() || newGeometry.y() != oldGeometry.y())
836  d->lastPos = mapFromScene(d->lastScenePos);
837 }
838 
840  const QVariant &value)
841 {
843  switch (change) {
845  if (acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse()))
846  setHovered(!d->hovered);
847  break;
848  default:
849  break;
850  }
851 
852  return QDeclarativeItem::itemChange(change, value);
853 }
854 
870 {
871  return acceptHoverEvents();
872 }
873 
875 {
877  if (h == acceptHoverEvents())
878  return;
879 
882  if (d->hovered != isUnderMouse())
883  setHovered(!d->hovered);
884 }
885 
897 {
898  Q_D(const QDeclarativeMouseArea);
899  return d->hovered;
900 }
901 
910 {
911  Q_D(const QDeclarativeMouseArea);
912  return d->pressed;
913 }
914 
916 {
918  if (d->hovered != h) {
919  d->hovered = h;
921  d->hovered ? emit entered() : emit exited();
922  }
923 }
924 
950 Qt::MouseButtons QDeclarativeMouseArea::acceptedButtons() const
951 {
952  return acceptedMouseButtons();
953 }
954 
956 {
957  if (buttons != acceptedMouseButtons()) {
958  setAcceptedMouseButtons(buttons);
960  }
961 }
962 
964 {
966  bool dragged = d->drag && d->drag->active();
967  bool isclick = d->pressed == true && p == false && dragged == false && d->hovered == true;
968 
969  if (d->pressed != p) {
970  d->pressed = p;
971  QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress);
972  if (d->pressed) {
973  if (!d->doubleClick)
974  emit pressed(&me);
975  me.setX(d->lastPos.x());
976  me.setY(d->lastPos.y());
979  } else {
980  emit released(&me);
981  me.setX(d->lastPos.x());
982  me.setY(d->lastPos.y());
984  if (isclick && !d->longPress && !d->doubleClick)
985  emit clicked(&me);
986  }
987 
988  return me.isAccepted();
989  }
990  return false;
991 }
992 
994 {
996  if (!d->drag)
997  d->drag = new QDeclarativeDrag;
998  return d->drag;
999 }
1000 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
This function is called to handle this item&#39;s changes in geometry from oldGeometry to newGeometry...
void pressAndHold(QDeclarativeMouseEvent *mouse)
bool hoverEnabled() const
QGraphicsObject * target
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
bool active() const
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item...
QDeclarativeParserStatus ** d
bool pressed() const
qreal y
the y position of the item
void hoverMoveEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover move events for this item...
Axis axis() const
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover leave events for this item...
virtual bool event(QEvent *)
void filterChildrenChanged()
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
void maximumYChanged()
static Qt::MouseButtons buttons
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
Qt::MouseButtons pressedButtons() const
void doubleClicked(QDeclarativeMouseEvent *mouse)
long ASN1_INTEGER_get ASN1_INTEGER * a
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse doubleclick events for thi...
void minimumXChanged()
T * qobject_cast(QObject *object)
Definition: qobject.h:375
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse press events for this item...
QGraphicsItem * mouseGrabberItem() const
Returns the current mouse grabber item, or 0 if no item is currently grabbing the mouse...
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
void setPreventStealing(bool prevent)
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
QDeclarativeMouseArea(QDeclarativeItem *parent=0)
This handler is called when the mouse enters the mouse area.
QRectF boundingRect() const
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover leave events for this item...
bool contains(const QPointF &p) const
Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false...
Definition: qrect.cpp:2349
void minimumYChanged()
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse doubleclick events for thi...
void released(QDeclarativeMouseEvent *mouse)
void mousePressEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse press events for this item...
QGraphicsObject * target() const
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
bool filterChildren() const
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool isUnderMouse() const
Returns true if this item is currently under the mouse cursor in one of the views; otherwise...
static const int PressAndHoldDelay
The QDeclarativeItem class provides the most basic of all visual items in QML.
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item...
qreal mouseX() const
#define emit
Definition: qobjectdefs.h:76
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover move events for this item...
Qt::MouseButtons acceptedButtons() const
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover enter events for this item...
void setAcceptedButtons(Qt::MouseButtons buttons)
static int startDragDistance()
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
This event handler can be reimplemented in a subclass to process context menu events.
bool sendMouseEvent(QGraphicsSceneMouseEvent *event)
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
This function is called to handle this item&#39;s changes in geometry from oldGeometry to newGeometry...
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
This event handler can be reimplemented in a subclass to process context menu events.
QPointF mapFromScene(const QPointF &point) const
Maps the point point, which is in this item&#39;s scene&#39;s coordinate system, to this item&#39;s coordinate sy...
QDeclarativeDrag(QObject *parent=0)
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object...
void setTarget(QGraphicsObject *)
qreal y() const
This convenience function is equivalent to calling pos().
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
This event handler, for event event, can be reimplemented to receive hover enter events for this item...
QDeclarativeItem * parentItem() const
Returns the QDeclarativeItem parent of this item.
virtual QVariant itemChange(GraphicsItemChange, const QVariant &)
Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is not called during initial widget p...
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is not called during initial widget p...
QPointF scenePos() const
Returns the mouse cursor position in scene coordinates.
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
void clicked(QDeclarativeMouseEvent *mouse)
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void setAcceptHoverEvents(bool enabled)
If enabled is true, this item will accept hover events; otherwise, it will ignore them...
qreal x() const
This convenience function is equivalent to calling pos().
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
if(void) toggleToolbarShown
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
bool sceneEventFilter(QGraphicsItem *i, QEvent *e)
Filters events for the item watched.
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise, false is returned.
qreal mouseY() const
static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
Definition: qtestmouse.h:71
virtual bool sceneEvent(QEvent *)
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
void setAccepted(bool accepted)
bool keepMouseGrab() const
Returns a value indicating whether mouse input should remain with this item exclusively.
QPointF buttonDownPos(Qt::MouseButton button) const
Returns the mouse cursor position in item coordinates where the specified button was clicked...
void mousePositionChanged(QDeclarativeMouseEvent *mouse)
void setAcceptedMouseButtons(Qt::MouseButtons buttons)
Sets the mouse buttons that this item accepts mouse events for.
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse release events for this it...
QGraphicsObject * _target
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
bool acceptHoverEvents() const
Returns true if an item accepts hover events (QGraphicsSceneHoverEvent); otherwise, returns false.
void ungrabMouse()
Releases the mouse grab.
qreal x
the x position of the item
The QGraphicsObject class provides a base class for all graphics items that require signals...
void positionChanged(QDeclarativeMouseEvent *mouse)
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event)
Filters events for the item watched.
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
QPointF mapToScene(const QPointF &point) const
Maps the point point, which is in this item&#39;s coordinate system, to the scene&#39;s coordinate system...
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse release events for this it...
void grabMouse()
Grabs the mouse input.
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent...
void maximumXChanged()
void setKeepMouseGrab(bool)
The flag indicating whether the mouse should remain with this item is set to keep.
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
QDeclarativeDrag * drag()
Reason reason() const
Returns the reason for the context menu event.
Qt::MouseButtons acceptedMouseButtons() const
Returns the mouse buttons that this item accepts mouse events for.
MouseButton
Definition: qnamespace.h:150
bool preventStealing() const
The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework...