Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QQuickMouseArea Class Reference

#include <qquickmousearea_p.h>

+ Inheritance diagram for QQuickMouseArea:
+ Collaboration diagram for QQuickMouseArea:

Signals

void hoveredChanged ()
 
void pressedChanged ()
 
void enabledChanged ()
 
 Q_REVISION (2, 5) void scrollGestureEnabledChanged()
 
void pressedButtonsChanged ()
 
void acceptedButtonsChanged ()
 
void hoverEnabledChanged ()
 
void positionChanged (QQuickMouseEvent *mouse)
 
void mouseXChanged (QQuickMouseEvent *mouse)
 
void mouseYChanged (QQuickMouseEvent *mouse)
 
void preventStealingChanged ()
 
void propagateComposedEventsChanged ()
 
void pressed (QQuickMouseEvent *mouse)
 
void pressAndHold (QQuickMouseEvent *mouse)
 
void released (QQuickMouseEvent *mouse)
 
void clicked (QQuickMouseEvent *mouse)
 
void doubleClicked (QQuickMouseEvent *mouse)
 
void entered ()
 
void exited ()
 
void canceled ()
 
 Q_REVISION (2, 4) void containsPressChanged()
 
 Q_REVISION (2, 9) void pressAndHoldIntervalChanged()
 
- Signals inherited from QQuickItem
void childrenRectChanged (const QRectF &)
 
void baselineOffsetChanged (qreal)
 
void stateChanged (const QString &)
 
void focusChanged (bool)
 
void activeFocusChanged (bool)
 
Q_REVISION(6, 7) void focusPolicyChanged(Qt Q_REVISION (2, 1) void activeFocusOnTabChanged(bool)
 
void parentChanged (QQuickItem *)
 
void transformOriginChanged (TransformOrigin)
 
void smoothChanged (bool)
 
void antialiasingChanged (bool)
 
void clipChanged (bool)
 
 Q_REVISION (2, 1) void windowChanged(QQuickWindow *window)
 
void childrenChanged ()
 
void opacityChanged ()
 
void enabledChanged ()
 
void visibleChanged ()
 
void visibleChildrenChanged ()
 
void rotationChanged ()
 
void scaleChanged ()
 
void xChanged ()
 
void yChanged ()
 
void widthChanged ()
 
void heightChanged ()
 
void zChanged ()
 
void implicitWidthChanged ()
 
void implicitHeightChanged ()
 
 Q_REVISION (2, 11) void containmentMaskChanged()
 
 Q_REVISION (6, 0) void paletteChanged()
 
 Q_REVISION (6, 0) void paletteCreated()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QQuickMouseArea (QQuickItem *parent=nullptr)
 \qmltype MouseArea \instantiates QQuickMouseArea \inqmlmodule QtQuick
 
 ~QQuickMouseArea ()
 
qreal mouseX () const
 \qmlproperty real QtQuick::MouseArea::mouseX \qmlproperty real QtQuick::MouseArea::mouseY These properties hold the coordinates of the mouse cursor.
 
qreal mouseY () const
 
bool isEnabled () const
 \qmlproperty bool QtQuick::MouseArea::enabled This property holds whether the item accepts mouse events.
 
void setEnabled (bool)
 
bool isScrollGestureEnabled () const
 \qmlproperty bool QtQuick::MouseArea::scrollGestureEnabled
 
void setScrollGestureEnabled (bool)
 
bool hovered () const
 \qmlproperty bool QtQuick::MouseArea::containsMouse This property holds whether the mouse is currently inside the mouse area.
 
bool isPressed () const
 \qmlproperty bool QtQuick::MouseArea::pressed This property holds whether any of the \l acceptedButtons are currently pressed.
 
bool containsPress () const
 \qmlproperty bool QtQuick::MouseArea::containsPress
 
Qt::MouseButtons pressedButtons () const
 \qmlproperty MouseButtons QtQuick::MouseArea::pressedButtons This property holds the mouse buttons currently pressed.
 
Qt::MouseButtons acceptedButtons () const
 \qmlproperty Qt::MouseButtons QtQuick::MouseArea::acceptedButtons This property holds the mouse buttons that the mouse area reacts to.
 
void setAcceptedButtons (Qt::MouseButtons buttons)
 
bool hoverEnabled () const
 \qmlproperty bool QtQuick::MouseArea::hoverEnabled This property holds whether hover events are handled.
 
void setHoverEnabled (bool h)
 
bool preventStealing () const
 \qmlproperty bool QtQuick::MouseArea::preventStealing This property holds whether the mouse events may be stolen from this MouseArea.
 
void setPreventStealing (bool prevent)
 
bool propagateComposedEvents () const
 \qmlproperty bool QtQuick::MouseArea::propagateComposedEvents This property holds whether composed mouse events will automatically propagate to other MouseAreas that overlap with this MouseArea but are lower in the visual stacking order.
 
void setPropagateComposedEvents (bool propagate)
 
int pressAndHoldInterval () const
 \qmlproperty Qt::CursorShape QtQuick::MouseArea::cursorShape This property holds the cursor shape for this mouse area.
 
void setPressAndHoldInterval (int interval)
 
void resetPressAndHoldInterval ()
 
- Public Member Functions inherited from QQuickItem
 QQuickItem (QQuickItem *parent=nullptr)
 Constructs a QQuickItem with the given parent.
 
 ~QQuickItem () override
 Destroys the QQuickItem.
 
QQuickWindowwindow () const
 Returns the window in which this item is rendered.
 
QQuickItemparentItem () const
 
void setParentItem (QQuickItem *parent)
 
void stackBefore (const QQuickItem *)
 Moves the specified sibling item to the index before this item within the list of children.
 
void stackAfter (const QQuickItem *)
 Moves the specified sibling item to the index after this item within the list of children.
 
QRectF childrenRect ()
 \qmlpropertygroup QtQuick::Item::childrenRect \qmlproperty real QtQuick::Item::childrenRect.x \qmlproperty real QtQuick::Item::childrenRect.y \qmlproperty real QtQuick::Item::childrenRect.width \qmlproperty real QtQuick::Item::childrenRect.height \readonly
 
QList< QQuickItem * > childItems () const
 Returns the children of this item.
 
bool clip () const
 \qmlproperty bool QtQuick::Item::clip This property holds whether clipping is enabled.
 
void setClip (bool)
 
QString state () const
 \qmlproperty string QtQuick::Item::state
 
void setState (const QString &)
 
qreal baselineOffset () const
 \qmlproperty int QtQuick::Item::baselineOffset
 
void setBaselineOffset (qreal)
 
QQmlListProperty< QQuickTransformtransform ()
 
qreal x () const
 
qreal y () const
 
QPointF position () const
 
void setX (qreal)
 
void setY (qreal)
 
void setPosition (const QPointF &)
 
QBindable< qrealbindableX ()
 
QBindable< qrealbindableY ()
 
qreal width () const
 
void setWidth (qreal)
 
void resetWidth ()
 
void setImplicitWidth (qreal)
 
qreal implicitWidth () const
 Returns the width of the item that is implied by other properties that determine the content.
 
QBindable< qrealbindableWidth ()
 
qreal height () const
 
void setHeight (qreal)
 
void resetHeight ()
 
void setImplicitHeight (qreal)
 
qreal implicitHeight () const
 
QBindable< qrealbindableHeight ()
 
QSizeF size () const
 
void setSize (const QSizeF &size)
 
TransformOrigin transformOrigin () const
 
void setTransformOrigin (TransformOrigin)
 
QPointF transformOriginPoint () const
 
void setTransformOriginPoint (const QPointF &)
 
qreal z () const
 
void setZ (qreal)
 
qreal rotation () const
 
void setRotation (qreal)
 
qreal scale () const
 
void setScale (qreal)
 
qreal opacity () const
 
void setOpacity (qreal)
 
bool isVisible () const
 
void setVisible (bool)
 
bool isEnabled () const
 
void setEnabled (bool)
 
bool smooth () const
 
void setSmooth (bool)
 
bool activeFocusOnTab () const
 \qmlproperty bool QtQuick::Item::activeFocusOnTab
 
void setActiveFocusOnTab (bool)
 
bool antialiasing () const
 
void setAntialiasing (bool)
 
void resetAntialiasing ()
 
Flags flags () const
 Returns the item flags for this item.
 
void setFlag (Flag flag, bool enabled=true)
 Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disabled.
 
void setFlags (Flags flags)
 Enables the specified flags for this item.
 
virtual QRectF boundingRect () const
 Returns the extents of the item in its own coordinate system: a rectangle from {0, 0} to \l width() and \l height().
 
virtual QRectF clipRect () const
 Returns the rectangular area within this item that is currently visible in \l viewportItem(), if there is a viewport and the \l ItemObservesViewport flag is set; otherwise, the extents of this item in its own coordinate system: a rectangle from {0, 0} to \l width() and \l height().
 
QQuickItemviewportItem () const
 If the \l ItemObservesViewport flag is set, returns the nearest parent with the \l ItemIsViewport flag.
 
bool hasActiveFocus () const
 
bool hasFocus () const
 
void setFocus (bool)
 
void setFocus (bool focus, Qt::FocusReason reason)
 
bool isFocusScope () const
 Returns true if this item is a focus scope, and false otherwise.
 
QQuickItemscopedFocusItem () const
 If this item is a focus scope, this returns the item in its focus chain that currently has focus.
 
Qt::FocusPolicy focusPolicy () const
 
void setFocusPolicy (Qt::FocusPolicy policy)
 Sets the focus policy of this item to policy.
 
bool isAncestorOf (const QQuickItem *child) const
 Returns true if this item is an ancestor of child (i.e., if this item is child's parent, or one of child's parent's ancestors).
 
Qt::MouseButtons acceptedMouseButtons () const
 Returns the mouse buttons accepted by this item.
 
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 Sets the mouse buttons accepted by this item to buttons.
 
bool acceptHoverEvents () const
 Returns whether hover events are accepted by this item.
 
void setAcceptHoverEvents (bool enabled)
 If enabled is true, this sets the item to accept hover events; otherwise, hover events are not accepted by this item.
 
bool acceptTouchEvents () const
 Returns whether touch events are accepted by this item.
 
void setAcceptTouchEvents (bool accept)
 If enabled is true, this sets the item to accept touch events; otherwise, touch events are not accepted by this item.
 
bool isUnderMouse () const
 
void grabMouse ()
 
void ungrabMouse ()
 
bool keepMouseGrab () const
 Returns whether mouse input should exclusively remain with this item.
 
void setKeepMouseGrab (bool)
 Sets whether the mouse input should remain exclusively with this item.
 
bool filtersChildMouseEvents () const
 Returns whether pointer events intended for this item's children should be filtered through this item.
 
void setFiltersChildMouseEvents (bool filter)
 Sets whether pointer events intended for this item's children should be filtered through this item.
 
void grabTouchPoints (const QList< int > &ids)
 
void ungrabTouchPoints ()
 
bool keepTouchGrab () const
 Returns whether the touch points grabbed by this item should exclusively remain with this item.
 
void setKeepTouchGrab (bool)
 Sets whether the touch points grabbed by this item should remain exclusively with this item.
 
 Q_REVISION (2, 4) Q_INVOKABLE bool grabToImage(const QJSValue &callback
 
QSharedPointer< QQuickItemGrabResultgrabToImage (const QSize &targetSize=QSize())
 Grabs the item into an in-memory image.
 
virtual Q_INVOKABLE bool contains (const QPointF &point) const
 \qmlmethod bool QtQuick::Item::contains(point point)
 
QObjectcontainmentMask () const
 
void setContainmentMask (QObject *mask)
 
QTransform itemTransform (QQuickItem *, bool *) const
 \qmlmethod point QtQuick::Item::mapFromItem(Item item, real x, real y) \qmlmethod point QtQuick::Item::mapFromItem(Item item, point p) \qmlmethod rect QtQuick::Item::mapFromItem(Item item, real x, real y, real width, real height) \qmlmethod rect QtQuick::Item::mapFromItem(Item item, rect r)
 
QPointF mapToScene (const QPointF &point) const
 Maps the given point in this item's coordinate system to the equivalent point within the scene's coordinate system, and returns the mapped coordinate.
 
QRectF mapRectToItem (const QQuickItem *item, const QRectF &rect) const
 Maps the given rect in this item's coordinate system to the equivalent rectangular area within item's coordinate system, and returns the mapped rectangle value.
 
QRectF mapRectToScene (const QRectF &rect) const
 Maps the given rect in this item's coordinate system to the equivalent rectangular area within the scene's coordinate system, and returns the mapped rectangle value.
 
QPointF mapFromScene (const QPointF &point) const
 Maps the given point in the scene's coordinate system to the equivalent point within this item's coordinate system, and returns the mapped coordinate.
 
QRectF mapRectFromItem (const QQuickItem *item, const QRectF &rect) const
 Maps the given rect in item's coordinate system to the equivalent rectangular area within this item's coordinate system, and returns the mapped rectangle value.
 
QRectF mapRectFromScene (const QRectF &rect) const
 Maps the given rect in the scene's coordinate system to the equivalent rectangular area within this item's coordinate system, and returns the mapped rectangle value.
 
void polish ()
 Schedules a polish event for this item.
 
Q_INVOKABLE QPointF mapFromItem (const QQuickItem *item, const QPointF &point) const
 Maps the given point in item's coordinate system to the equivalent point within this item's coordinate system, and returns the mapped coordinate.
 
Q_INVOKABLE QPointF mapFromItem (const QQuickItem *item, qreal x, qreal y)
 
Q_INVOKABLE QRectF mapFromItem (const QQuickItem *item, const QRectF &rect) const
 
Q_INVOKABLE QRectF mapFromItem (const QQuickItem *item, qreal x, qreal y, qreal width, qreal height) const
 
Q_INVOKABLE QPointF mapToItem (const QQuickItem *item, const QPointF &point) const
 Maps the given point in this item's coordinate system to the equivalent point within item's coordinate system, and returns the mapped coordinate.
 
Q_INVOKABLE QPointF mapToItem (const QQuickItem *item, qreal x, qreal y)
 
Q_INVOKABLE QRectF mapToItem (const QQuickItem *item, const QRectF &rect) const
 
Q_INVOKABLE QRectF mapToItem (const QQuickItem *item, qreal x, qreal y, qreal width, qreal height) const
 
 Q_REVISION (2, 7) Q_INVOKABLE QPointF mapFromGlobal(qreal x
 
 Q_REVISION (2, 7) Q_INVOKABLE QPointF mapFromGlobal(const QPointF &point) const
 
 Q_REVISION (2, 7) Q_INVOKABLE QPointF mapToGlobal(qreal x
 
 Q_REVISION (2, 7) Q_INVOKABLE QPointF mapToGlobal(const QPointF &point) const
 
Q_INVOKABLE void forceActiveFocus ()
 \qmlmethod point QtQuick::Item::mapToItem(Item item, real x, real y) \qmlmethod point QtQuick::Item::mapToItem(Item item, point p) \qmlmethod rect QtQuick::Item::mapToItem(Item item, real x, real y, real width, real height) \qmlmethod rect QtQuick::Item::mapToItem(Item item, rect r)
 
Q_INVOKABLE void forceActiveFocus (Qt::FocusReason reason)
 \qmlmethod QtQuick::Item::forceActiveFocus(Qt::FocusReason reason) This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Forces active focus on the item with the given reason.
 
 Q_REVISION (2, 1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward
 
Q_INVOKABLE QQuickItemchildAt (qreal x, qreal y) const
 \qmlmethod QtQuick::Item::childAt(real x, real y)
 
 Q_REVISION (6, 3) Q_INVOKABLE void ensurePolished()
 
 Q_REVISION (6, 3) Q_INVOKABLE void dumpItemTree() const
 
virtual bool isTextureProvider () const
 Returns true if this item is a texture provider.
 
virtual QSGTextureProvidertextureProvider () const
 Returns the texture provider for an item.
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 
- Public Member Functions inherited from QQmlParserStatus
 QQmlParserStatus ()
 
virtual ~QQmlParserStatus ()
 

Protected Member Functions

void setHovered (bool)
 
bool setPressed (Qt::MouseButton button, bool p, Qt::MouseEventSource source)
 
bool sendMouseEvent (QMouseEvent *event)
 
void mousePressEvent (QMouseEvent *event) override
 This event handler can be reimplemented in a subclass to receive mouse press events for an item.
 
void mouseReleaseEvent (QMouseEvent *event) override
 This event handler can be reimplemented in a subclass to receive mouse release events for an item.
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 This event handler can be reimplemented in a subclass to receive mouse double-click events for an item.
 
void mouseMoveEvent (QMouseEvent *event) override
 This event handler can be reimplemented in a subclass to receive mouse move events for an item.
 
void mouseUngrabEvent () override
 This event handler can be reimplemented in a subclass to be notified when a mouse ungrab event has occurred on this item.
 
void touchUngrabEvent () override
 This event handler can be reimplemented in a subclass to be notified when a touch ungrab event has occurred on this item.
 
void hoverEnterEvent (QHoverEvent *event) override
 This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
 
void hoverMoveEvent (QHoverEvent *event) override
 This event handler can be reimplemented in a subclass to receive hover-move events for an item.
 
void hoverLeaveEvent (QHoverEvent *event) override
 This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
 
bool childMouseEventFilter (QQuickItem *i, QEvent *e) override
 Reimplement this method to filter the pointer events that are received by this item's children.
 
void timerEvent (QTimerEvent *event) override
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
void geometryChange (const QRectF &newGeometry, const QRectF &oldGeometry) override
 
void itemChange (ItemChange change, const ItemChangeData &value) override
 Called when change occurs for this item.
 
QSGNodeupdatePaintNode (QSGNode *, UpdatePaintNodeData *) override
 \qmlpropertygroup QtQuick::MouseArea::drag \qmlproperty Item QtQuick::MouseArea::drag.target \qmlproperty bool QtQuick::MouseArea::drag.active \qmlproperty enumeration QtQuick::MouseArea::drag.axis \qmlproperty real QtQuick::MouseArea::drag.minimumX \qmlproperty real QtQuick::MouseArea::drag.maximumX \qmlproperty real QtQuick::MouseArea::drag.minimumY \qmlproperty real QtQuick::MouseArea::drag.maximumY \qmlproperty bool QtQuick::MouseArea::drag.filterChildren \qmlproperty real QtQuick::MouseArea::drag.threshold \qmlproperty bool QtQuick::MouseArea::drag.smoothed
 
- Protected Member Functions inherited from QQuickItem
bool event (QEvent *) override
 \reimp
 
bool isComponentComplete () const
 Returns true if construction of the QML component is complete; otherwise returns false.
 
bool widthValid () const
 Returns whether the width property has been set explicitly.
 
bool heightValid () const
 Returns whether the height property has been set explicitly.
 
void setImplicitSize (qreal, qreal)
 
void classBegin () override
 \reimp Derived classes should call the base class method before adding their own action to perform at classBegin.
 
void componentComplete () override
 \reimp Derived classes should call the base class method before adding their own actions to perform at componentComplete.
 
virtual void keyPressEvent (QKeyEvent *event)
 This event handler can be reimplemented in a subclass to receive key press events for an item.
 
virtual void keyReleaseEvent (QKeyEvent *event)
 This event handler can be reimplemented in a subclass to receive key release events for an item.
 
virtual void focusInEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive focus-in events for an item.
 
virtual void focusOutEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive focus-out events for an item.
 
virtual void touchEvent (QTouchEvent *event)
 This event handler can be reimplemented in a subclass to receive touch events for an item.
 
virtual void releaseResources ()
 This function is called when an item should release graphics resources which are not already managed by the nodes returned from QQuickItem::updatePaintNode().
 
virtual void updatePolish ()
 This function should perform any layout as required for this item.
 
 QQuickItem (QQuickItemPrivate &dd, QQuickItem *parent=nullptr)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Properties

qreal mouseX
 
qreal mouseY
 
bool containsMouse
 
bool pressed
 
bool enabled
 
bool scrollGestureEnabled
 
Qt::MouseButtons pressedButtons
 
Qt::MouseButtons acceptedButtons
 
bool hoverEnabled
 
bool preventStealing
 
bool propagateComposedEvents
 
bool containsPress
 
int pressAndHoldInterval
 
- Properties inherited from QQuickItem
QQuickItemparent
 \qmlproperty Item QtQuick::Item::parent This property holds the visual parent of the item.
 
qreal x
 \qmlproperty real QtQuick::Item::x \qmlproperty real QtQuick::Item::y \qmlproperty real QtQuick::Item::width \qmlproperty real QtQuick::Item::height
 
qreal y
 Defines the item's y position relative to its parent.
 
qreal z
 \qmlproperty real QtQuick::Item::z
 
qreal width
 This property holds the width of this item.
 
qreal height
 This property holds the height of this item.
 
qreal opacity
 \qmlproperty real QtQuick::Item::opacity
 
bool enabled
 \qmlproperty bool QtQuick::Item::enabled
 
bool visible
 \qmlproperty bool QtQuick::Item::visible
 
Qt::FocusPolicy focusPolicy
 \qmlproperty enumeration QtQuick::Item::focusPolicy
 
qreal rotation
 \qmlproperty real QtQuick::Item::rotation This property holds the rotation of the item in degrees clockwise around its transformOrigin.
 
qreal scale
 \qmlproperty real QtQuick::Item::scale This property holds the scale factor for this item.
 
TransformOrigin transformOrigin
 \qmlproperty enumeration QtQuick::Item::transformOrigin This property holds the origin point around which scale and rotation transform.
 
QPointF transformOriginPoint
 
QQmlListProperty< QQuickTransformtransform
 \qmlproperty list<Transform> QtQuick::Item::transform This property holds the list of transformations to apply.
 
bool smooth
 \qmlproperty bool QtQuick::Item::smooth
 
bool antialiasing
 \qmlproperty bool QtQuick::Item::antialiasing
 
qreal implicitWidth
 
qreal implicitHeight
 
QObjectcontainmentMask
 \qmlproperty QObject* QtQuick::Item::containmentMask
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Additional Inherited Members

- Public Types inherited from QQuickItem
enum  Flag {
  ItemClipsChildrenToShape = 0x01 , ItemIsFocusScope = 0x04 , ItemHasContents = 0x08 , ItemAcceptsDrops = 0x10 ,
  ItemIsViewport = 0x20 , ItemObservesViewport = 0x40
}
 \qmltype Item \instantiates QQuickItem \inherits QtObject \inqmlmodule QtQuick More...
 
enum  ItemChange {
  ItemChildAddedChange , ItemChildRemovedChange , ItemSceneChange , ItemVisibleHasChanged ,
  ItemParentHasChanged , ItemOpacityHasChanged , ItemActiveFocusHasChanged , ItemRotationHasChanged ,
  ItemAntialiasingHasChanged , ItemDevicePixelRatioHasChanged , ItemEnabledHasChanged
}
 Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes. More...
 
enum  TransformOrigin {
  TopLeft , Top , TopRight , Left ,
  Center , Right , BottomLeft , Bottom ,
  BottomRight
}
 \variable QQuickItem::ItemChangeData::realValue The numeric value that has changed: \l {QQuickItem::opacity()}{opacity}, \l {QQuickItem::rotation()}{rotation}, or \l {QScreen::devicePixelRatio}{device pixel ratio}. More...
 
- Public Slots inherited from QQuickItem
void update ()
 Schedules a call to updatePaintNode() for this item.
 
- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Public Attributes inherited from QQuickItem
const QSizetargetSize = QSize())
 
qreal y const
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

Definition at line 29 of file qquickmousearea_p.h.

Constructor & Destructor Documentation

◆ QQuickMouseArea()

QQuickMouseArea::QQuickMouseArea ( QQuickItem * parent = nullptr)

\qmltype MouseArea \instantiates QQuickMouseArea \inqmlmodule QtQuick

Enables simple mouse handling. \inherits Item

A MouseArea is an invisible item that is typically used in conjunction with a visible item in order to provide mouse handling for that item. By effectively acting as a proxy, the logic for mouse handling can be contained within a MouseArea item.

The \l enabled property is used to enable and disable mouse handling for the proxied item. When disabled, the mouse area becomes transparent to mouse events.

MouseArea is an invisible Item, but it has a visible property. When set to false, the mouse area becomes transparent to mouse events.

The \l pressed read-only property indicates whether or not the user is holding down a mouse button over the mouse area. This property is often used in bindings between properties in a user interface. The containsMouse read-only property indicates the presence of the mouse cursor over the mouse area but, by default, only when a mouse button is held down; see the containsMouse documentation for details.

Information about the mouse position and button clicks are provided via signals for which event handler properties are defined. The most commonly used involved handling mouse presses and clicks: onClicked, onDoubleClicked, onPressed, onReleased and onPressAndHold. It's also possible to handle mouse wheel events via the onWheel signal.

If a MouseArea overlaps with the area of other MouseArea items, you can choose to propagate clicked, doubleClicked and pressAndHold events to these other items by setting propagateComposedEvents to true and rejecting events that should be propagated. See the propagateComposedEvents documentation for details.

By default, MouseArea items only report mouse clicks and not changes to the position of the mouse cursor. Setting the hoverEnabled property ensures that handlers defined for onPositionChanged, onEntered and onExited are used and that the containsMouse property is updated even when no mouse buttons are pressed.

Definition at line 387 of file qquickmousearea.cpp.

References Qt::ArrowCursor, d, and setCursor().

+ Here is the call graph for this function:

◆ ~QQuickMouseArea()

QQuickMouseArea::~QQuickMouseArea ( )

Definition at line 400 of file qquickmousearea.cpp.

Member Function Documentation

◆ acceptedButtons()

Qt::MouseButtons QQuickMouseArea::acceptedButtons ( ) const

\qmlproperty Qt::MouseButtons QtQuick::MouseArea::acceptedButtons This property holds the mouse buttons that the mouse area reacts to.

To specify that the MouseArea will react to multiple buttons, Qt::MouseButtons flag values are combined using the "|" (or) operator:

MouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton }
Qt::MouseButtons acceptedButtons
Definition qcompare.h:63

To indicate that all possible mouse buttons are to be accepted, the special value 'Qt.AllButtons' may be used:

MouseArea { acceptedButtons: Qt.AllButtons }

The default value is Qt.LeftButton.

Definition at line 1216 of file qquickmousearea.cpp.

References QQuickItem::acceptedMouseButtons().

+ Here is the call graph for this function:

◆ acceptedButtonsChanged

void QQuickMouseArea::acceptedButtonsChanged ( )
signal

Referenced by setAcceptedButtons().

+ Here is the caller graph for this function:

◆ canceled

void QQuickMouseArea::canceled ( )
signal

Referenced by sendMouseEvent().

+ Here is the caller graph for this function:

◆ childMouseEventFilter()

bool QQuickMouseArea::childMouseEventFilter ( QQuickItem * item,
QEvent * event )
overrideprotectedvirtual

Reimplement this method to filter the pointer events that are received by this item's children.

This method will only be called if filtersChildMouseEvents() is true.

Return true if the specified event should not be passed on to the specified child item, and false otherwise. If you return true, you should also \l {QEvent::accept()}{accept} or \l {QEvent::ignore()}{ignore} the event, to signal if event propagation should stop or continue. The event will, however, always be sent to all childMouseEventFilters up the parent chain.

Note
Despite the name, this function filters all QPointerEvent instances during delivery to all children (typically mouse, touch, and tablet events). When overriding this function in a subclass, we suggest writing generic event-handling code using only the accessors found in QPointerEvent. Alternatively you can switch on event->type() and/or event->device()->type() to handle different event types in different ways.
Filtering is just one way to share responsibility in case of gestural ambiguity (for example on press, you don't know whether the user will tap or drag). Another way is to call QPointerEvent::addPassiveGrabber() on press, so as to non-exclusively monitor the progress of the QEventPoint. In either case, the item or pointer handler that is monitoring can steal the exclusive grab later on, when it becomes clear that the gesture fits the pattern that it is expecting.
See also
setFiltersChildMouseEvents()

Reimplemented from QQuickItem.

Definition at line 987 of file qquickmousearea.cpp.

References QQuickItem::childMouseEventFilter(), d, i, QQuickItem::isVisible(), QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseMove, QT_CONFIG, sendMouseEvent(), and QEvent::type().

+ Here is the call graph for this function:

◆ clicked

void QQuickMouseArea::clicked ( QQuickMouseEvent * mouse)
signal

Referenced by setPressed().

+ Here is the caller graph for this function:

◆ containsPress()

bool QQuickMouseArea::containsPress ( ) const

\qmlproperty bool QtQuick::MouseArea::containsPress

Since
5.4 This is a convenience property equivalent to {pressed && containsMouse}, i.e. it holds whether any of the \l acceptedButtons are currently pressed and the mouse is currently within the MouseArea.

This property is particularly useful for highlighting an item while the mouse is pressed within its bounds.

See also
pressed, containsMouse

Definition at line 1177 of file qquickmousearea.cpp.

References d.

◆ doubleClicked

void QQuickMouseArea::doubleClicked ( QQuickMouseEvent * mouse)
signal

Referenced by mouseDoubleClickEvent().

+ Here is the caller graph for this function:

◆ enabledChanged

void QQuickMouseArea::enabledChanged ( )
signal

Referenced by setEnabled().

+ Here is the caller graph for this function:

◆ entered

void QQuickMouseArea::entered ( )
signal

Referenced by setHovered().

+ Here is the caller graph for this function:

◆ exited

void QQuickMouseArea::exited ( )
signal

Referenced by setHovered().

+ Here is the caller graph for this function:

◆ geometryChange()

void QQuickMouseArea::geometryChange ( const QRectF & newGeometry,
const QRectF & oldGeometry )
overrideprotectedvirtual
Since
6.0

This function is called to handle this item's changes in geometry from oldGeometry to newGeometry. If the two geometries are the same, it doesn't do anything.

Derived classes must call the base class method within their implementation.

Reimplemented from QQuickItem.

Definition at line 1037 of file qquickmousearea.cpp.

References d, QQuickItem::geometryChange(), QQuickItem::mapFromScene(), QQuickItem::mapToScene(), QRectF::x(), and QRectF::y().

+ Here is the call graph for this function:

◆ hovered()

bool QQuickMouseArea::hovered ( ) const

\qmlproperty bool QtQuick::MouseArea::containsMouse This property holds whether the mouse is currently inside the mouse area.

Warning
If hoverEnabled is false, containsMouse will be true when the mouse is pressed while the mouse cursor is inside the MouseArea. But if you set {mouse.accepted = false} in an onPressed handler, containsMouse will remain false because the press was rejected.

Definition at line 1149 of file qquickmousearea.cpp.

References d.

◆ hoveredChanged

void QQuickMouseArea::hoveredChanged ( )
signal

Referenced by sendMouseEvent(), and setHovered().

+ Here is the caller graph for this function:

◆ hoverEnabled()

bool QQuickMouseArea::hoverEnabled ( ) const

\qmlproperty bool QtQuick::MouseArea::hoverEnabled This property holds whether hover events are handled.

By default, mouse events are only handled in response to a button event, or when a button is pressed. Hover enables handling of all mouse events even when no mouse button is pressed.

This property affects the containsMouse property and the onEntered, onExited and onPositionChanged signals.

Definition at line 1122 of file qquickmousearea.cpp.

◆ hoverEnabledChanged

void QQuickMouseArea::hoverEnabledChanged ( )
signal

Referenced by setHoverEnabled().

+ Here is the caller graph for this function:

◆ hoverEnterEvent()

void QQuickMouseArea::hoverEnterEvent ( QHoverEvent * event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive hover-enter events for an item.

The event information is provided by the event parameter.

Hover events are only provided if acceptHoverEvents() is true.

\input item.qdocinc accepting-events

Reimplemented from QQuickItem.

Definition at line 809 of file qquickmousearea.cpp.

References d, emit, QQuickItem::hoverEnterEvent(), mouseXChanged(), mouseYChanged(), Qt::NoButton, QQuickMouseEvent::reset(), setHovered(), and QQuickMouseEvent::setPosition().

+ Here is the call graph for this function:

◆ hoverLeaveEvent()

void QQuickMouseArea::hoverLeaveEvent ( QHoverEvent * event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive hover-leave events for an item.

The event information is provided by the event parameter.

Hover events are only provided if acceptHoverEvents() is true.

\input item.qdocinc accepting-events

Reimplemented from QQuickItem.

Definition at line 859 of file qquickmousearea.cpp.

References d, QQuickItem::hoverLeaveEvent(), and setHovered().

+ Here is the call graph for this function:

◆ hoverMoveEvent()

void QQuickMouseArea::hoverMoveEvent ( QHoverEvent * event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive hover-move events for an item.

The event information is provided by the event parameter.

Hover events are only provided if acceptHoverEvents() is true.

\input item.qdocinc accepting-events

Reimplemented from QQuickItem.

Definition at line 838 of file qquickmousearea.cpp.

References d, emit, QQuickItem::hoverMoveEvent(), mouseXChanged(), mouseYChanged(), Qt::NoButton, positionChanged(), QQuickMouseEvent::reset(), and QQuickMouseEvent::setPosition().

+ Here is the call graph for this function:

◆ isEnabled()

bool QQuickMouseArea::isEnabled ( ) const

\qmlproperty bool QtQuick::MouseArea::enabled This property holds whether the item accepts mouse events.

Note
Due to historical reasons, this property is not equivalent to Item.enabled. It only affects mouse events, and its effect does not propagate to child items.

By default, this property is true.

Definition at line 445 of file qquickmousearea.cpp.

References d.

◆ isPressed()

bool QQuickMouseArea::isPressed ( ) const

\qmlproperty bool QtQuick::MouseArea::pressed This property holds whether any of the \l acceptedButtons are currently pressed.

Definition at line 1159 of file qquickmousearea.cpp.

References d.

◆ isScrollGestureEnabled()

bool QQuickMouseArea::isScrollGestureEnabled ( ) const

\qmlproperty bool QtQuick::MouseArea::scrollGestureEnabled

Since
5.5

This property controls whether this MouseArea responds to scroll gestures from non-mouse devices, such as the 2-finger flick gesture on a trackpad. If set to false, the \l wheel signal be emitted only when the wheel event comes from an actual mouse with a wheel, while scroll gesture events will pass through to any other Item that will handle them. For example, the user might perform a flick gesture while the cursor is over an item containing a MouseArea, intending to interact with a Flickable which is underneath. Setting this property to false will allow the PinchArea to handle the mouse wheel or the pinch gesture, while the Flickable handles the flick gesture.

By default, this property is true.

Definition at line 477 of file qquickmousearea.cpp.

References d.

◆ itemChange()

void QQuickMouseArea::itemChange ( ItemChange change,
const ItemChangeData & value )
overrideprotectedvirtual

Called when change occurs for this item.

value contains extra information relating to the change, when applicable.

If you re-implement this method in a subclass, be sure to call

virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]

typically at the end of your implementation, to ensure the \l windowChanged() signal will be emitted.

Reimplemented from QQuickItem.

Definition at line 1048 of file qquickmousearea.cpp.

References QDateTime::currentSecsSinceEpoch(), d, QQuickDeliveryAgentPrivate::deliverHoverEvent(), QQuickWindowPrivate::deliveryAgentPrivate(), QQuickWindowPrivate::get(), hoverEnabled, QQuickItem::isUnderMouse(), QQuickItem::isVisible(), QQuickItem::itemChange(), QQuickItem::ItemEnabledHasChanged, QQuickItem::ItemVisibleHasChanged, QGuiApplicationPrivate::lastCursorPosition, QQuickItem::mapFromScene(), Qt::NoModifier, and setHovered().

+ Here is the call graph for this function:

◆ mouseDoubleClickEvent()

void QQuickMouseArea::mouseDoubleClickEvent ( QMouseEvent * event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive mouse double-click events for an item.

The event information is provided by the event parameter.

\input item.qdocinc accepting-events

Reimplemented from QQuickItem.

Definition at line 785 of file qquickmousearea.cpp.

References d, QQuickMouseAreaPrivate::DoubleClick, doubleClicked(), emit, QQuickMouseEvent::isAccepted(), QQuickItem::mouseDoubleClickEvent(), QQuickMouseEvent::reset(), and QQuickMouseEvent::setAccepted().

+ Here is the call graph for this function:

◆ mouseMoveEvent()

void QQuickMouseArea::mouseMoveEvent ( QMouseEvent * event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive mouse move events for an item.

The event information is provided by the event parameter.

In order to receive mouse movement events, the preceding mouse press event must be accepted (by overriding \l mousePressEvent(), for example) and \l acceptedMouseButtons() must return the relevant mouse button.

\input item.qdocinc accepting-events

Reimplemented from QQuickItem.

Definition at line 650 of file qquickmousearea.cpp.

References QQuickItem::acceptedMouseButtons(), QQuickItem::contains(), d, QQuickDeliveryAgentPrivate::dragOverThreshold(), emit, QQuickItem::keepMouseGrab(), QQuickItem::mapFromScene(), QQuickItem::mouseMoveEvent(), mouseXChanged(), mouseYChanged(), QQuickItem::parentItem(), positionChanged(), qBound(), QQuickMouseEvent::reset(), setHovered(), QQuickItem::setKeepMouseGrab(), QQuickMouseEvent::setPosition(), QPointF::setX(), QPointF::x(), Qt::XAxis, QQuickDrag::XAxis, QPointF::y(), Qt::YAxis, and QQuickDrag::YAxis.

Referenced by sendMouseEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mousePressEvent()

void QQuickMouseArea::mousePressEvent ( QMouseEvent * event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive mouse press events for an item.

The event information is provided by the event parameter.

In order to receive mouse press events, \l acceptedMouseButtons() must return the relevant mouse button.

\input item.qdocinc accepting-events

Reimplemented from QQuickItem.

Definition at line 626 of file qquickmousearea.cpp.

References QQuickItem::acceptedMouseButtons(), d, QQuickItem::mousePressEvent(), pressAndHoldInterval, setHovered(), QQuickItem::setKeepMouseGrab(), and setPressed().

Referenced by sendMouseEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mouseReleaseEvent()

void QQuickMouseArea::mouseReleaseEvent ( QMouseEvent * event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive mouse release events for an item.

The event information is provided by the event parameter.

In order to receive mouse release events, the preceding mouse press event must be accepted (by overriding \l mousePressEvent(), for example) and \l acceptedMouseButtons() must return the relevant mouse button.

\input item.qdocinc accepting-events

Reimplemented from QQuickItem.

Definition at line 756 of file qquickmousearea.cpp.

References d, hoverEnabled, QQuickItem::mouseReleaseEvent(), setHovered(), QQuickItem::setKeepMouseGrab(), setPressed(), and QQuickItem::window().

Referenced by sendMouseEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mouseUngrabEvent()

void QQuickMouseArea::mouseUngrabEvent ( )
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to be notified when a mouse ungrab event has occurred on this item.

Reimplemented from QQuickItem.

Definition at line 919 of file qquickmousearea.cpp.

◆ mouseX()

qreal QQuickMouseArea::mouseX ( ) const

\qmlproperty real QtQuick::MouseArea::mouseX \qmlproperty real QtQuick::MouseArea::mouseY These properties hold the coordinates of the mouse cursor.

If the hoverEnabled property is false then these properties will only be valid while a button is pressed, and will remain valid as long as the button is held down even if the mouse is moved outside the area.

By default, this property is false.

If hoverEnabled is true then these properties will be valid when: \list

  • no button is pressed, but the mouse is within the MouseArea (containsMouse is true).
  • a button is pressed and held, even if it has since moved out of the area. \endlist

The coordinates are relative to the MouseArea.

Definition at line 423 of file qquickmousearea.cpp.

References d.

◆ mouseXChanged

void QQuickMouseArea::mouseXChanged ( QQuickMouseEvent * mouse)
signal

Referenced by hoverEnterEvent(), hoverMoveEvent(), mouseMoveEvent(), and setPressed().

+ Here is the caller graph for this function:

◆ mouseY()

qreal QQuickMouseArea::mouseY ( ) const

Definition at line 429 of file qquickmousearea.cpp.

References d.

◆ mouseYChanged

void QQuickMouseArea::mouseYChanged ( QQuickMouseEvent * mouse)
signal

Referenced by hoverEnterEvent(), hoverMoveEvent(), mouseMoveEvent(), and setPressed().

+ Here is the caller graph for this function:

◆ positionChanged

void QQuickMouseArea::positionChanged ( QQuickMouseEvent * mouse)
signal

Referenced by hoverMoveEvent(), and mouseMoveEvent().

+ Here is the caller graph for this function:

◆ pressAndHold

void QQuickMouseArea::pressAndHold ( QQuickMouseEvent * mouse)
signal

Referenced by timerEvent().

+ Here is the caller graph for this function:

◆ pressAndHoldInterval()

int QQuickMouseArea::pressAndHoldInterval ( ) const

\qmlproperty Qt::CursorShape QtQuick::MouseArea::cursorShape This property holds the cursor shape for this mouse area.

Note that on platforms that do not display a mouse cursor this may have no effect.

The available cursor shapes are: \list

In order to only set a mouse cursor shape for a region without reacting to mouse events set the acceptedButtons to none:

MouseArea { cursorShape: Qt.IBeamCursor; acceptedButtons: Qt.NoButton }

The default value is Qt.ArrowCursor.

See also
Qt::CursorShape

\qmlproperty int QtQuick::MouseArea::pressAndHoldInterval

Since
5.9

This property overrides the elapsed time in milliseconds before pressAndHold is emitted.

If not explicitly set – or after reset – the value follows QStyleHints::mousePressAndHoldInterval.

Typically it's sufficient to set this property globally using the application style hint. This property should be used when varying intervals are needed for certain MouseAreas.

See also
pressAndHold

Definition at line 1370 of file qquickmousearea.cpp.

References d, and QGuiApplication::styleHints().

+ Here is the call graph for this function:

◆ pressed

void QQuickMouseArea::pressed ( QQuickMouseEvent * mouse)
signal

◆ pressedButtons()

Qt::MouseButtons QQuickMouseArea::pressedButtons ( ) const

\qmlproperty MouseButtons QtQuick::MouseArea::pressedButtons This property holds the mouse buttons currently pressed.

It contains a bitwise combination of: \list

The code below displays "right" when the right mouse buttons is pressed:

Text {
text: mouseArea.pressedButtons & Qt.RightButton ? "right" : ""
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
MouseArea {
id: mouseArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
}
}
Note
this property only handles buttons specified in \l acceptedButtons.
See also
acceptedButtons

Definition at line 620 of file qquickmousearea.cpp.

References d.

◆ pressedButtonsChanged

void QQuickMouseArea::pressedButtonsChanged ( )
signal

Referenced by sendMouseEvent(), and setPressed().

+ Here is the caller graph for this function:

◆ pressedChanged

void QQuickMouseArea::pressedChanged ( )
signal

Referenced by sendMouseEvent(), and setPressed().

+ Here is the caller graph for this function:

◆ preventStealing()

bool QQuickMouseArea::preventStealing ( ) const

\qmlproperty bool QtQuick::MouseArea::preventStealing This property holds whether the mouse events may be stolen from this MouseArea.

If a MouseArea is placed within an item that filters child mouse events, such as Flickable, the mouse events may be stolen from the MouseArea if a gesture is recognized by the parent item, e.g. a flick gesture. If preventStealing is set to true, no item will steal the mouse events.

Note that setting preventStealing to true once an item has started stealing events will have no effect until the next press event.

By default this property is false.

Definition at line 508 of file qquickmousearea.cpp.

References d.

◆ preventStealingChanged

void QQuickMouseArea::preventStealingChanged ( )
signal

Referenced by setPreventStealing().

+ Here is the caller graph for this function:

◆ propagateComposedEvents()

bool QQuickMouseArea::propagateComposedEvents ( ) const

\qmlproperty bool QtQuick::MouseArea::propagateComposedEvents This property holds whether composed mouse events will automatically propagate to other MouseAreas that overlap with this MouseArea but are lower in the visual stacking order.

By default, this property is false.

MouseArea contains several composed events: clicked, doubleClicked and pressAndHold. These are composed of basic mouse events, like pressed, and can be propagated differently in comparison to basic events.

If propagateComposedEvents is set to true, then composed events will be automatically propagated to other MouseAreas in the same location in the scene. Each event is propagated to the next \l enabled MouseArea beneath it in the stacking order, propagating down this visual hierarchy until a MouseArea accepts the event. Unlike pressed events, composed events will not be automatically accepted if no handler is present.

For example, below is a yellow \l Rectangle that contains a blue \l Rectangle. The blue rectangle is the top-most item in the hierarchy of the visual stacking order; it will visually rendered above the yellow rectangle. Since the blue rectangle sets propagateComposedEvents to true, and also sets \l MouseEvent::accepted to false for all received clicked events, any clicked events it receives are propagated to the MouseArea of the yellow rectangle beneath it.

\qml import QtQuick 2.0

Rectangle { color: "yellow" width: 100; height: 100

MouseArea { anchors.fill: parent onClicked: console.log("clicked yellow") }

Rectangle { color: "blue" width: 50; height: 50

MouseArea { anchors.fill: parent propagateComposedEvents: true onClicked: (mouse)=> { console.log("clicked blue") mouse.accepted = false } } } } \endqml

Clicking on the blue rectangle will cause the onClicked handler of its child MouseArea to be invoked; the event will then be propagated to the MouseArea of the yellow rectangle, causing its own onClicked handler to be invoked.

This property greatly simplifies the usecase of when you want to have overlapping MouseAreas handling the composed events together. For example: if you want one MouseArea to handle clicked signals and the other to handle pressAndHold, or if you want one MouseArea to handle clicked most of the time, but pass it through when certain conditions are met.

Definition at line 585 of file qquickmousearea.cpp.

References d.

◆ propagateComposedEventsChanged

void QQuickMouseArea::propagateComposedEventsChanged ( )
signal

Referenced by setPropagateComposedEvents().

+ Here is the caller graph for this function:

◆ Q_REVISION [1/3]

QQuickMouseArea::Q_REVISION ( 2 ,
4  )
signal

◆ Q_REVISION [2/3]

QQuickMouseArea::Q_REVISION ( 2 ,
5  )
signal

◆ Q_REVISION [3/3]

QQuickMouseArea::Q_REVISION ( 2 ,
9  )
signal

◆ released

void QQuickMouseArea::released ( QQuickMouseEvent * mouse)
signal

Referenced by setPressed().

+ Here is the caller graph for this function:

◆ resetPressAndHoldInterval()

void QQuickMouseArea::resetPressAndHoldInterval ( )

Definition at line 1386 of file qquickmousearea.cpp.

References d, and emit.

◆ sendMouseEvent()

bool QQuickMouseArea::sendMouseEvent ( QMouseEvent * event)
protected

Definition at line 930 of file qquickmousearea.cpp.

References canceled(), QQuickItem::contains(), d, emit, QQuickItem::grabMouse(), hoveredChanged(), QQuickItem::mapFromScene(), QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseMove, mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), pressedButtonsChanged(), pressedChanged(), qCDebug, QPointerEvent::setAccepted(), and QQuickItem::window().

Referenced by childMouseEventFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAcceptedButtons()

void QQuickMouseArea::setAcceptedButtons ( Qt::MouseButtons buttons)

Definition at line 1221 of file qquickmousearea.cpp.

References acceptedButtonsChanged(), QQuickItem::acceptedMouseButtons(), emit, and QQuickItem::setAcceptedMouseButtons().

+ Here is the call graph for this function:

◆ setEnabled()

void QQuickMouseArea::setEnabled ( bool a)

Definition at line 451 of file qquickmousearea.cpp.

References d, emit, enabledChanged(), and QQuickItem::setAcceptHoverEvents().

+ Here is the call graph for this function:

◆ setHovered()

void QQuickMouseArea::setHovered ( bool h)
protected

Definition at line 1183 of file qquickmousearea.cpp.

References d, emit, entered(), exited(), hoveredChanged(), and qCDebug.

Referenced by hoverEnterEvent(), hoverLeaveEvent(), itemChange(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and setPressed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHoverEnabled()

void QQuickMouseArea::setHoverEnabled ( bool h)

Definition at line 1127 of file qquickmousearea.cpp.

References d, emit, hoverEnabledChanged(), and QQuickItem::setAcceptHoverEvents().

+ Here is the call graph for this function:

◆ setPressAndHoldInterval()

void QQuickMouseArea::setPressAndHoldInterval ( int interval)

Definition at line 1377 of file qquickmousearea.cpp.

References d, and emit.

◆ setPressed()

bool QQuickMouseArea::setPressed ( Qt::MouseButton button,
bool p,
Qt::MouseEventSource source )
protected

Definition at line 1229 of file qquickmousearea.cpp.

References button, QQuickMouseAreaPrivate::Click, clicked(), d, emit, hoverEnabled, QQuickMouseEvent::isAccepted(), mouseXChanged(), mouseYChanged(), Qt::NoButton, pressed, pressedButtonsChanged(), pressedChanged(), Q_UNUSED, released(), QQuickMouseEvent::reset(), QQuickMouseEvent::setAccepted(), setHovered(), and QQuickMouseEvent::setPosition().

Referenced by mousePressEvent(), and mouseReleaseEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPreventStealing()

void QQuickMouseArea::setPreventStealing ( bool prevent)

Definition at line 514 of file qquickmousearea.cpp.

References d, emit, preventStealingChanged(), and QQuickItem::setKeepMouseGrab().

+ Here is the call graph for this function:

◆ setPropagateComposedEvents()

void QQuickMouseArea::setPropagateComposedEvents ( bool propagate)

Definition at line 591 of file qquickmousearea.cpp.

References d, emit, propagateComposedEventsChanged(), and QQuickItem::setKeepMouseGrab().

+ Here is the call graph for this function:

◆ setScrollGestureEnabled()

void QQuickMouseArea::setScrollGestureEnabled ( bool e)

Definition at line 483 of file qquickmousearea.cpp.

References d, and emit.

◆ timerEvent()

void QQuickMouseArea::timerEvent ( QTimerEvent * event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive timer events for the object.

QChronoTimer provides higher-level interfaces to the timer functionality, and also more general information about timers. The timer event is passed in the event parameter.

See also
startTimer(), killTimer(), event()

Reimplemented from QObject.

Definition at line 1010 of file qquickmousearea.cpp.

References d, emit, QQuickMouseEvent::isAccepted(), Qt::MouseEventSynthesizedByQt, pressAndHold(), QQuickMouseAreaPrivate::PressAndHold, QQuickMouseEvent::reset(), and QQuickMouseEvent::setAccepted().

+ Here is the call graph for this function:

◆ touchUngrabEvent()

void QQuickMouseArea::touchUngrabEvent ( )
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to be notified when a touch ungrab event has occurred on this item.

Reimplemented from QQuickItem.

Definition at line 924 of file qquickmousearea.cpp.

◆ updatePaintNode()

QSGNode * QQuickMouseArea::updatePaintNode ( QSGNode * oldNode,
UpdatePaintNodeData * data )
overrideprotectedvirtual

\qmlpropertygroup QtQuick::MouseArea::drag \qmlproperty Item QtQuick::MouseArea::drag.target \qmlproperty bool QtQuick::MouseArea::drag.active \qmlproperty enumeration QtQuick::MouseArea::drag.axis \qmlproperty real QtQuick::MouseArea::drag.minimumX \qmlproperty real QtQuick::MouseArea::drag.maximumX \qmlproperty real QtQuick::MouseArea::drag.minimumY \qmlproperty real QtQuick::MouseArea::drag.maximumY \qmlproperty bool QtQuick::MouseArea::drag.filterChildren \qmlproperty real QtQuick::MouseArea::drag.threshold \qmlproperty bool QtQuick::MouseArea::drag.smoothed

drag provides a convenient way to make an item draggable.

\list

  • drag.target specifies the id of the item to drag.
  • drag.active specifies if the target item is currently being dragged.
  • drag.axis specifies whether dragging can be done horizontally (Drag.XAxis), vertically (Drag.YAxis), or both (Drag.XAndYAxis)
  • drag.minimum and drag.maximum limit how far the target can be dragged along the corresponding axes. \endlist

The following example displays a \l Rectangle that can be dragged along the X-axis. The opacity of the rectangle is reduced when it is dragged to the right.

Rectangle {
id: container
width: 600; height: 200
Rectangle {
id: rect
width: 50; height: 50
color: "red"
opacity: (600.0 - rect.x) / 600
MouseArea {
anchors.fill: parent
drag.target: rect
drag.axis: Drag.XAxis
drag.minimumX: 0
drag.maximumX: container.width - rect.width
}
}
}
Note
Items cannot be dragged if they are anchored for the requested drag.axis. For example, if anchors.left or anchors.right was set for rect in the above example, it cannot be dragged along the X-axis. This can be avoided by settng the anchor value to undefined in an \l {pressed}{onPressed} handler.

If drag.filterChildren is set to true, a drag can override descendant MouseAreas. This enables a parent MouseArea to handle drags, for example, while descendants handle clicks:

import QtQuick
Rectangle {
width: 480
height: 320
Rectangle {
x: 30; y: 30
width: 300; height: 240
color: "lightsteelblue"
MouseArea {
anchors.fill: parent
drag.target: parent;
drag.axis: "XAxis"
drag.minimumX: 30
drag.maximumX: 150
drag.filterChildren: true
Rectangle {
color: "yellow"
x: 50; y : 50
width: 100; height: 100
MouseArea {
anchors.fill: parent
onClicked: console.log("Clicked")
}
}
}
}
}

drag.threshold determines the threshold in pixels of when the drag operation should start. By default this is bound to a platform dependent value. This property was added in Qt Quick 2.2.

If drag.smoothed is true, the target will be moved only after the drag operation has started. If set to false, the target will be moved straight to the current mouse position. By default, this property is true. This property was added in Qt Quick 2.4

See the \l Drag attached property and \l DropArea if you want to make a drop.

Reimplemented from QQuickItem.

Definition at line 1454 of file qquickmousearea.cpp.

References d, QQuickItem::height, Q_UNUSED, QSGInternalRectangleNode::setColor(), QSGInternalRectangleNode::setRect(), QSGInternalRectangleNode::update(), and QQuickItem::width.

+ Here is the call graph for this function:

Property Documentation

◆ acceptedButtons

Qt::MouseButtons QQuickMouseArea::acceptedButtons
readwrite

Definition at line 40 of file qquickmousearea_p.h.

◆ containsMouse

bool QQuickMouseArea::containsMouse
read

Definition at line 35 of file qquickmousearea_p.h.

◆ containsPress

bool QQuickMouseArea::containsPress
read

Definition at line 50 of file qquickmousearea_p.h.

◆ enabled

bool QQuickMouseArea::enabled
readwrite

Definition at line 37 of file qquickmousearea_p.h.

◆ hoverEnabled

bool QQuickMouseArea::hoverEnabled
readwrite

Definition at line 41 of file qquickmousearea_p.h.

Referenced by itemChange(), mouseReleaseEvent(), and setPressed().

◆ mouseX

qreal QQuickMouseArea::mouseX
read

Definition at line 33 of file qquickmousearea_p.h.

◆ mouseY

qreal QQuickMouseArea::mouseY
read

Definition at line 34 of file qquickmousearea_p.h.

◆ pressAndHoldInterval

int QQuickMouseArea::pressAndHoldInterval
readwrite

Definition at line 51 of file qquickmousearea_p.h.

Referenced by mousePressEvent().

◆ pressed

bool QQuickMouseArea::pressed
read

Definition at line 36 of file qquickmousearea_p.h.

Referenced by setPressed().

◆ pressedButtons

Qt::MouseButtons QQuickMouseArea::pressedButtons
read

Definition at line 39 of file qquickmousearea_p.h.

◆ preventStealing

bool QQuickMouseArea::preventStealing
readwrite

Definition at line 45 of file qquickmousearea_p.h.

◆ propagateComposedEvents

bool QQuickMouseArea::propagateComposedEvents
readwrite

Definition at line 46 of file qquickmousearea_p.h.

◆ scrollGestureEnabled

bool QQuickMouseArea::scrollGestureEnabled
readwrite

Definition at line 38 of file qquickmousearea_p.h.


The documentation for this class was generated from the following files: