Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QQuickItem Class Reference

The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}. More...

#include <qquickitem.h>

Inherits QObject, and QQmlParserStatus.

Inherited by QDeclarativeGeoMap, QDeclarativeGeoMapItemBase, QDeclarativeGeoMapItemGroup, QGfxSourceProxyME, QQuick3DViewport, QQuickAnimatedSprite, QQuickBasicBusyIndicator, QQuickBasicProgressBar, QQuickCanvasItem, QQuickColorInputs, QQuickContentItem, QQuickControl, QQuickDropArea, QQuickFlickable, QQuickFlickableContentItem, QQuickFlickableContentItem, QQuickFlipable, QQuickFocusScope, QQuickFramebufferObject, QQuickIconLabel, QQuickImplicitSizeItem, QQuickLayout, QQuickLayoutItemProxy, QQuickMaterialBusyIndicator, QQuickMaterialProgressBar, QQuickMaterialRipple, QQuickMouseArea, QQuickMultiEffect, QQuickMultiPointTouchArea, QQuickOverlay, QQuickPaintedItem, QQuickParticleAffector, QQuickParticleEmitter, QQuickParticlePainter, QQuickParticleSystem, QQuickPathView, QQuickPdfSelection, QQuickPinchArea, QQuickRectangle, QQuickRectangularShadow, QQuickRepeater, QQuickRhiItem, QQuickRootItem, QQuickShaderEffect, QQuickShaderEffectSource, QQuickShape, QQuickSpriteSequence, QQuickStyleItem, QQuickTumblerView, QQuickUniversalBusyIndicator, QQuickUniversalProgressBar, QQuickVectorImage, QQuickVectorImageGenerator::Utils::ViewBoxItem, QQuickVideoOutput, QWaylandMouseTracker, QWaylandQtShellChrome, and QWaylandQuickItem.

+ Collaboration diagram for QQuickItem:

Classes

class  ItemChangeData
 \inmodule QtQuick More...
 
struct  UpdatePaintNodeData
 

Public Types

enum  Flag {
  ItemClipsChildrenToShape = 0x01 , ItemIsFocusScope = 0x04 , ItemHasContents = 0x08 , ItemAcceptsDrops = 0x10 ,
  ItemIsViewport = 0x20 , ItemObservesViewport = 0x40
}
 \qmltype Item \nativetype QQuickItem \inherits QtObject \inqmlmodule QtQuick More...
 
enum  ItemChange {
  ItemChildAddedChange , ItemChildRemovedChange , ItemSceneChange , ItemVisibleHasChanged ,
  ItemParentHasChanged , ItemOpacityHasChanged , ItemActiveFocusHasChanged , ItemRotationHasChanged ,
  ItemAntialiasingHasChanged , ItemDevicePixelRatioHasChanged , ItemEnabledHasChanged , ItemScaleHasChanged ,
  ItemTransformHasChanged
}
 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 {QQuickItem::scale()}{scale}, or \l {QScreen::devicePixelRatio}{device pixel ratio}. More...
 

Public Slots

void update ()
 Schedules a call to updatePaintNode() for this item.
 
- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 

Signals

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

 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 ()
 

Public Attributes

const QSizetargetSize = QSize())
 
qreal y const
 

Protected Member Functions

bool event (QEvent *) override
 \reimp
 
bool isComponentComplete () const
 Returns true if construction of the QML component is complete; otherwise returns false.
 
virtual void itemChange (ItemChange, const ItemChangeData &)
 Called when change occurs for this item.
 
virtual void geometryChange (const QRectF &newGeometry, const QRectF &oldGeometry)
 
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 mousePressEvent (QMouseEvent *event)
 This event handler can be reimplemented in a subclass to receive mouse press events for an item.
 
virtual void mouseMoveEvent (QMouseEvent *event)
 This event handler can be reimplemented in a subclass to receive mouse move events for an item.
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 This event handler can be reimplemented in a subclass to receive mouse release events for an item.
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 This event handler can be reimplemented in a subclass to receive mouse double-click events for an item.
 
virtual void mouseUngrabEvent ()
 This event handler can be reimplemented in a subclass to be notified when a mouse ungrab event has occurred on this item.
 
virtual void touchUngrabEvent ()
 This event handler can be reimplemented in a subclass to be notified when a touch ungrab event has occurred on this item.
 
virtual void touchEvent (QTouchEvent *event)
 This event handler can be reimplemented in a subclass to receive touch events for an item.
 
virtual void hoverEnterEvent (QHoverEvent *event)
 This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
 
virtual void hoverMoveEvent (QHoverEvent *event)
 This event handler can be reimplemented in a subclass to receive hover-move events for an item.
 
virtual void hoverLeaveEvent (QHoverEvent *event)
 This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
 
virtual bool childMouseEventFilter (QQuickItem *, QEvent *)
 Reimplement this method to filter the pointer events that are received by this item's children.
 
virtual QSGNodeupdatePaintNode (QSGNode *, UpdatePaintNodeData *)
 Called on the render thread when it is time to sync the state of the item with the scene graph.
 
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 timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
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

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
 

Friends

class QQuickDeliveryAgentPrivate
 
class QSGRenderer
 
class QAccessibleQuickItem
 
class QQuickAccessibleAttached
 
class QQuickAnchorChanges
 
Q_QUICK_EXPORT QDebug operator<< (QDebug debug, QQuickItem *item)
 

Additional Inherited Members

- 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)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.

\inmodule QtQuick

All visual items in Qt Quick inherit from QQuickItem. Although a QQuickItem instance has no visual appearance, it defines all the attributes that are common across visual items, such as x and y position, width and height, \l {Positioning with Anchors}{anchoring} and key handling support.

You can subclass QQuickItem to provide your own custom visual item that inherits these features.

Definition at line 62 of file qquickitem.h.

Member Enumeration Documentation

◆ Flag

\qmltype Item \nativetype QQuickItem \inherits QtObject \inqmlmodule QtQuick

A basic visual QML type.

The Item type is the base type for all visual items in Qt Quick.

All visual items in Qt Quick inherit from Item. Although an Item object has no visual appearance, it defines all the attributes that are common across visual items, such as x and y position, width and height, \l {Positioning with Anchors}{anchoring} and key handling support.

The Item type can be useful for grouping several items under a single root visual item. For example:

\qml import QtQuick 2.0

Item { Image { source: "tile.png" } Image { x: 80 width: 100 height: 100 source: "tile.png" } Image { x: 190 width: 100 height: 100 fillMode: Image.Tile source: "tile.png" } } \endqml

Enumerator
ItemClipsChildrenToShape 
ItemIsFocusScope 
ItemHasContents 
ItemAcceptsDrops 
ItemIsViewport 
ItemObservesViewport 

Definition at line 129 of file qquickitem.h.

◆ ItemChange

Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.

\value ItemChildAddedChange A child was added. ItemChangeData::item contains the added child.

\value ItemChildRemovedChange A child was removed. ItemChangeData::item contains the removed child.

\value ItemSceneChange The item was added to or removed from a scene. The QQuickWindow rendering the scene is specified in using ItemChangeData::window. The window parameter is null when the item is removed from a scene.

\value ItemVisibleHasChanged The item's visibility has changed. ItemChangeData::boolValue contains the new visibility.

\value ItemParentHasChanged The item's parent has changed. ItemChangeData::item contains the new parent.

\value ItemOpacityHasChanged The item's opacity has changed. ItemChangeData::realValue contains the new opacity.

\value ItemActiveFocusHasChanged The item's focus has changed. ItemChangeData::boolValue contains whether the item has focus or not.

\value ItemRotationHasChanged The item's rotation has changed. ItemChangeData::realValue contains the new rotation.

\value ItemDevicePixelRatioHasChanged The device pixel ratio of the screen the item is on has changed. ItemChangedData::realValue contains the new device pixel ratio.

\value ItemAntialiasingHasChanged The antialiasing has changed. The current (boolean) value can be found in QQuickItem::antialiasing.

\value ItemEnabledHasChanged The item's enabled state has changed. ItemChangeData::boolValue contains the new enabled state. (since Qt 5.10)

\value ItemScaleHasChanged The item's scale has changed. ItemChangeData::realValue contains the scale. (since Qt 6.9)

\value ItemTransformHasChanged The item's transform has changed. This occurs when the item's position, size, rotation, scale, transformOrigin or attached transforms change. (since Qt 6.9)

Enumerator
ItemChildAddedChange 
ItemChildRemovedChange 
ItemSceneChange 
ItemVisibleHasChanged 
ItemParentHasChanged 
ItemOpacityHasChanged 
ItemActiveFocusHasChanged 
ItemRotationHasChanged 
ItemAntialiasingHasChanged 
ItemDevicePixelRatioHasChanged 
ItemEnabledHasChanged 
ItemScaleHasChanged 
ItemTransformHasChanged 

Definition at line 144 of file qquickitem.h.

◆ TransformOrigin

\variable QQuickItem::ItemChangeData::realValue The numeric value that has changed: \l {QQuickItem::opacity()}{opacity}, \l {QQuickItem::rotation()}{rotation}, or \l {QQuickItem::scale()}{scale}, or \l {QScreen::devicePixelRatio}{device pixel ratio}.

See also
QQuickItem::ItemChange

\variable QQuickItem::ItemChangeData::boolValue The boolean value that has changed: \l {QQuickItem::isVisible()}{visible}, \l {QQuickItem::isEnabled()}{enabled}, \l {QQuickItem::hasActiveFocus()}{activeFocus}, or \l {QQuickItem::antialiasing()}{antialiasing}.

See also
QQuickItem::ItemChange

\variable QQuickItem::ItemChangeData::item The item that has been added or removed as a \l{QQuickItem::childItems()}{child}, or the new \l{QQuickItem::parentItem()}{parent}.

See also
QQuickItem::ItemChange

\variable QQuickItem::ItemChangeData::window The \l{QQuickWindow}{window} in which the item has been shown, or nullptr if the item has been removed from a window.

See also
QQuickItem::ItemChange

Controls the point about which simple transforms like scale apply.

\value TopLeft The top-left corner of the item. \value Top The center point of the top of the item. \value TopRight The top-right corner of the item. \value Left The left most point of the vertical middle. \value Center The center of the item. \value Right The right most point of the vertical middle. \value BottomLeft The bottom-left corner of the item. \value Bottom The center point of the bottom of the item. \value BottomRight The bottom-right corner of the item.

See also
transformOrigin(), setTransformOrigin()
Enumerator
TopLeft 
Top 
TopRight 
Left 
Center 
Right 
BottomLeft 
Bottom 
BottomRight 

Definition at line 173 of file qquickitem.h.

Constructor & Destructor Documentation

◆ QQuickItem() [1/2]

QQuickItem::QQuickItem ( QQuickItem * parent = nullptr)
explicit

Constructs a QQuickItem with the given parent.

The parent will be used as both the \l {setParentItem()}{visual parent} and the \l QObject parent.

Definition at line 2358 of file qquickitem.cpp.

◆ ~QQuickItem()

QQuickItem::~QQuickItem ( )
override

Destroys the QQuickItem.

Definition at line 2377 of file qquickitem.cpp.

◆ QQuickItem() [2/2]

QQuickItem::QQuickItem ( QQuickItemPrivate & dd,
QQuickItem * parent = nullptr )
protected

Definition at line 2367 of file qquickitem.cpp.

Member Function Documentation

◆ acceptedMouseButtons()

Qt::MouseButtons QQuickItem::acceptedMouseButtons ( ) const

Returns the mouse buttons accepted by this item.

The default value is Qt::NoButton; that is, no mouse buttons are accepted.

If an item does not accept the mouse button for a particular mouse event, the mouse event will not be delivered to the item and will be delivered to the next item in the item hierarchy instead.

See also
acceptTouchEvents()

Definition at line 8067 of file qquickitem.cpp.

◆ acceptHoverEvents()

bool QQuickItem::acceptHoverEvents ( ) const

Returns whether hover events are accepted by this item.

The default value is false.

If this is false, then the item will not receive any hover events through the hoverEnterEvent(), hoverMoveEvent() and hoverLeaveEvent() functions.

Definition at line 8153 of file qquickitem.cpp.

◆ acceptTouchEvents()

bool QQuickItem::acceptTouchEvents ( ) const

Returns whether touch events are accepted by this item.

The default value is false.

If this is false, then the item will not receive any touch events through the touchEvent() function.

Since
5.10

Definition at line 8186 of file qquickitem.cpp.

◆ activeFocusChanged

void QQuickItem::activeFocusChanged ( bool )
signal

◆ activeFocusOnTab()

bool QQuickItem::activeFocusOnTab ( ) const

\qmlproperty bool QtQuick::Item::activeFocusOnTab

This property holds whether the item wants to be in the tab focus chain. By default, this is set to false.

The tab focus chain traverses elements by first visiting the parent, and then its children in the order they occur in the children property. Pressing the tab key on an item in the tab focus chain will move keyboard focus to the next item in the chain. Pressing BackTab (normally Shift+Tab) will move focus to the previous item.

To set up a manual tab focus chain, see \l KeyNavigation. Tab key events used by Keys or KeyNavigation have precedence over focus chain behavior; ignore the events in other key handlers to allow it to propagate.

Note
{QStyleHints::tabFocusBehavior}{tabFocusBehavior} can further limit focus to only specific types of controls, such as only text or list controls. This is the case on macOS, where focus to particular controls may be restricted based on system settings.
See also
QStyleHints::tabFocusBehavior, focusPolicy

This property holds whether the item wants to be in the tab focus chain. By default, this is set to false.

Note
{QStyleHints::tabFocusBehavior}{tabFocusBehavior} can further limit focus to only specific types of controls, such as only text or list controls. This is the case on macOS, where focus to particular controls may be restricted based on system settings.
See also
QStyleHints::tabFocusBehavior, focusPolicy

Definition at line 7005 of file qquickitem.cpp.

◆ antialiasing()

bool QQuickItem::antialiasing ( ) const

Definition at line 7047 of file qquickitem.cpp.

◆ antialiasingChanged

void QQuickItem::antialiasingChanged ( bool )
signal

◆ baselineOffset()

qreal QQuickItem::baselineOffset ( ) const

\qmlproperty int QtQuick::Item::baselineOffset

Specifies the position of the item's baseline in local coordinates.

The baseline of a \l Text item is the imaginary line on which the text sits. Controls containing text usually set their baseline to the baseline of their text.

For non-text items, a default baseline offset of 0 is used.

Specifies the position of the item's baseline in local coordinates.

The baseline of a \l Text item is the imaginary line on which the text sits. Controls containing text usually set their baseline to the baseline of their text.

For non-text items, a default baseline offset of 0 is used.

Definition at line 4548 of file qquickitem.cpp.

◆ baselineOffsetChanged

void QQuickItem::baselineOffsetChanged ( qreal )
signal

◆ bindableHeight()

QBindable< qreal > QQuickItem::bindableHeight ( )

Definition at line 7584 of file qquickitem.cpp.

◆ bindableWidth()

QBindable< qreal > QQuickItem::bindableWidth ( )

Definition at line 7375 of file qquickitem.cpp.

◆ bindableX()

QBindable< qreal > QQuickItem::bindableX ( )

Definition at line 7304 of file qquickitem.cpp.

◆ bindableY()

QBindable< qreal > QQuickItem::bindableY ( )

Definition at line 7309 of file qquickitem.cpp.

◆ boundingRect()

QRectF QQuickItem::boundingRect ( ) const
virtual

Returns the extents of the item in its own coordinate system: a rectangle from {0, 0} to \l width() and \l height().

Reimplemented in QQuickImage, QQuickText, QQuickTextEdit, and QQuickTextInput.

Definition at line 5815 of file qquickitem.cpp.

◆ childAt()

QQuickItem * QQuickItem::childAt ( qreal x,
qreal y ) const

\qmlmethod QtQuick::Item::childAt(real x, real y)

Returns the first visible child item found at point (x, y) within the coordinate system of this item.

Returns null if there is no such item.

Returns the first visible child item found at point (x, y) within the coordinate system of this item.

Returns \nullptr if there is no such item.

Definition at line 5032 of file qquickitem.cpp.

◆ childItems()

QList< QQuickItem * > QQuickItem::childItems ( ) const

Returns the children of this item.

Definition at line 3821 of file qquickitem.cpp.

◆ childMouseEventFilter()

bool QQuickItem::childMouseEventFilter ( QQuickItem * item,
QEvent * event )
protectedvirtual

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 in QQuickFlickable, QQuickMouseArea, QQuickMultiPointTouchArea, QQuickOverlay, QQuickPathView, QQuickPinchArea, QQuickPopupItem, QQuickScrollView, QQuickSplitView, QQuickStackView, QQuickSwipeDelegate, and QWaylandMouseTracker.

Definition at line 4416 of file qquickitem.cpp.

◆ childrenChanged

void QQuickItem::childrenChanged ( )
signal

◆ childrenRect()

QRectF QQuickItem::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

This read-only property holds the collective position and size of the item's children.

This property is useful if you need to access the collective geometry of an item's children in order to correctly size the item.

The geometry that is returned is local to the item. For example:

Item {
x: 50
y: 100
// prints: QRectF(-10, -20, 30, 40)
Component.onCompleted: print(childrenRect)
Item {
x: -10
y: -20
width: 30
height: 40
}
}

This property holds the collective position and size of the item's children.

This property is useful if you need to access the collective geometry of an item's children in order to correctly size the item.

The geometry that is returned is local to the item. For example:

Item {
x: 50
y: 100
// prints: QRectF(-10, -20, 30, 40)
Component.onCompleted: print(childrenRect)
Item {
x: -10
y: -20
width: 30
height: 40
}
}

Definition at line 3807 of file qquickitem.cpp.

◆ childrenRectChanged

void QQuickItem::childrenRectChanged ( const QRectF & )
signal

◆ classBegin()

void QQuickItem::classBegin ( )
overrideprotectedvirtual

\reimp Derived classes should call the base class method before adding their own action to perform at classBegin.

Implements QQmlParserStatus.

Reimplemented in QQuickLabel, QQuickRangeSlider, QQuickScrollBar, QQuickShape, QQuickSpinBox, QQuickTextArea, QQuickTextField, and QQuickWindowContainer.

Definition at line 5332 of file qquickitem.cpp.

◆ clip()

bool QQuickItem::clip ( ) const

\qmlproperty bool QtQuick::Item::clip This property holds whether clipping is enabled.

The default clip value is false.

If clipping is enabled, an item will clip its own painting, as well as the painting of its children, to its bounding rectangle.

Note
Clipping can affect rendering performance. See \l {Clipping} for more information.

This property holds whether clipping is enabled. The default clip value is false.

If clipping is enabled, an item will clip its own painting, as well as the painting of its children, to its bounding rectangle. If you set clipping during an item's paint operation, remember to re-set it to prevent clipping the rest of your scene.

Note
Clipping can affect rendering performance. See \l {Clipping} for more information.
For the sake of QML, setting clip to true also sets the \l ItemIsViewport flag, which sometimes acts as an optimization: child items that have the \l ItemObservesViewport flag may forego creating scene graph nodes that fall outside the viewport. But the ItemIsViewport flag can also be set independently.

Definition at line 3855 of file qquickitem.cpp.

◆ clipChanged

void QQuickItem::clipChanged ( bool )
signal

◆ clipRect()

QRectF QQuickItem::clipRect ( ) const
virtual

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().

This is the region intended to remain visible if \l clip is true. It can also be used in updatePaintNode() to limit the graphics added to the scene graph.

For example, a large drawing or a large text document might be shown in a Flickable that occupies only part of the application's Window: in that case, Flickable is the viewport item, and a custom content-rendering item may choose to omit scene graph nodes that fall outside the area that is currently visible. If the \l ItemObservesViewport flag is set, this area will change each time the user scrolls the content in the Flickable.

In case of nested viewport items, clipRect() is the intersection of the {boundingRect}s of all ancestors that have the \l ItemIsViewport flag set, mapped to the coordinate system of this item.

See also
boundingRect()

Reimplemented in QQuickClippedText, QQuickText, QQuickTextEdit, QQuickTextInput, and QQuickWindowContainer.

Definition at line 5842 of file qquickitem.cpp.

◆ componentComplete()

◆ containmentMask()

QObject * QQuickItem::containmentMask ( ) const

Definition at line 8734 of file qquickitem.cpp.

◆ contains()

bool QQuickItem::contains ( const QPointF & point) const
virtual

\qmlmethod bool QtQuick::Item::contains(point point)

Returns true if this item contains point, which is in local coordinates; returns false otherwise. This is the same check that is used for hit-testing a QEventPoint during event delivery, and is affected by \l containmentMask if it is set.

Returns true if this item contains point, which is in local coordinates; returns false otherwise.

This function can be overridden in order to handle point collisions in items with custom shapes. The default implementation checks whether the point is inside \l containmentMask() if it is set, or inside the bounding box otherwise.

Note
This method is used for hit-testing each QEventPoint during event delivery, so the implementation should be kept as lightweight as possible.

Reimplemented in QDeclarativeCircleMapItem, QDeclarativePolygonMapItem, QDeclarativePolylineMapItem, QDeclarativeRectangleMapItem, QQuickFlickableContentItem, QQuickFlickableContentItem, QQuickShape, and QQuickTextArea.

Definition at line 8650 of file qquickitem.cpp.

◆ enabledChanged

void QQuickItem::enabledChanged ( )
signal

◆ event()

bool QQuickItem::event ( QEvent * ev)
overrideprotectedvirtual

\reimp

Reimplemented from QObject.

Reimplemented in QQuickMenuBarItem, QQuickPinchArea, QQuickRhiItem, QQuickShaderEffect, QQuickStyleItem, QQuickTextEdit, and QQuickTextInput.

Definition at line 9061 of file qquickitem.cpp.

◆ filtersChildMouseEvents()

bool QQuickItem::filtersChildMouseEvents ( ) const

Returns whether pointer events intended for this item's children should be filtered through this item.

If both this item and a child item have acceptTouchEvents() true, then when a touch interaction occurs, this item will filter the touch event. But if either this item or the child cannot handle touch events, childMouseEventFilter() will be called with a synthesized mouse event.

See also
setFiltersChildMouseEvents(), childMouseEventFilter()

Definition at line 8105 of file qquickitem.cpp.

◆ flags()

QQuickItem::Flags QQuickItem::flags ( ) const

Returns the item flags for this item.

See also
setFlag()

Definition at line 7099 of file qquickitem.cpp.

◆ focusChanged

void QQuickItem::focusChanged ( bool )
signal

◆ focusInEvent()

void QQuickItem::focusInEvent ( QFocusEvent * event)
protectedvirtual

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

The event information is provided by the event parameter.

\input item.qdocinc accepting-events

If you do reimplement this function, you should call the base class implementation.

Reimplemented in QQuickComboBox, QQuickControl, QQuickPopupItem, QQuickRangeSlider, QQuickSpinBox, QQuickTextArea, QQuickTextEdit, QQuickTextField, and QQuickTextInput.

Definition at line 4144 of file qquickitem.cpp.

◆ focusOutEvent()

void QQuickItem::focusOutEvent ( QFocusEvent * event)
protectedvirtual

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

The event information is provided by the event parameter.

\input item.qdocinc accepting-events

Reimplemented in QQuickAbstractButton, QQuickComboBox, QQuickControl, QQuickPopupItem, QQuickTextArea, QQuickTextEdit, QQuickTextField, and QQuickTextInput.

Definition at line 4165 of file qquickitem.cpp.

◆ focusPolicy()

Qt::FocusPolicy QQuickItem::focusPolicy ( ) const

Definition at line 8011 of file qquickitem.cpp.

◆ forceActiveFocus() [1/2]

void QQuickItem::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)

Maps the point (x, y) or rect (x, y, width, height), which is in this item's coordinate system, to item's coordinate system, and returns a \l point or \l rect matching the mapped coordinate.

\input item.qdocinc mapping

If item is a null value, this maps the point or rect to the coordinate system of the \l{Scene Coordinates}{scene}.

The versions accepting point and rect are since Qt 5.15.

Since
5.7 \qmlmethod point QtQuick::Item::mapToGlobal(real x, real y)

Maps the point (x, y), which is in this item's coordinate system, to the global coordinate system, and returns a \l point matching the mapped coordinate.

\input item.qdocinc mapping

\qmlmethod QtQuick::Item::forceActiveFocus()

Forces active focus on the item.

This method sets focus on the item and ensures that all ancestor FocusScope objects in the object hierarchy are also given \l focus.

The reason for the focus change will be \l [CPP] Qt::OtherFocusReason. Use the overloaded method to specify the focus reason to enable better handling of the focus change.

See also
activeFocus

Forces active focus on the item.

This method sets focus on the item and ensures that all ancestor FocusScope objects in the object hierarchy are also given \l focus.

The reason for the focus change will be \l [CPP] Qt::OtherFocusReason. Use the overloaded method to specify the focus reason to enable better handling of the focus change.

See also
activeFocus

Definition at line 4951 of file qquickitem.cpp.

◆ forceActiveFocus() [2/2]

void QQuickItem::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.

This method sets focus on the item and ensures that all ancestor FocusScope objects in the object hierarchy are also given \l focus.

Since
5.1
See also
activeFocus, Qt::FocusReason

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.

This method sets focus on the item and ensures that all ancestor FocusScope objects in the object hierarchy are also given \l focus.

Since
5.1
See also
activeFocus, Qt::FocusReason

Definition at line 4981 of file qquickitem.cpp.

◆ geometryChange()

◆ grabMouse()

void QQuickItem::grabMouse ( )
Deprecated
Use QPointerEvent::setExclusiveGrabber().

Grabs the mouse input.

This item will receive all mouse events until ungrabMouse() is called. Usually this function should not be called, since accepting for example a mouse press event makes sure that the following events are delivered to the item. If an item wants to take over mouse events from the current receiver, it needs to call this function.

Warning
This function should be used with caution.
Deprecated
Use QPointerEvent::setExclusiveGrabber().

Grabs the mouse input.

This item will receive all mouse events until ungrabMouse() is called. Usually this function should not be called, since accepting for example a mouse press event makes sure that the following events are delivered to the item. If an item wants to take over mouse events from the current receiver, it needs to call this function.

Warning
This function should be used with caution.

Definition at line 8482 of file qquickitem.cpp.

◆ grabToImage()

bool QQuickItem::grabToImage ( const QSize & targetSize = QSize())

Grabs the item into an in-memory image.

\qmlmethod bool QtQuick::Item::grabToImage(callback, targetSize)

The grab happens asynchronously and the signal QQuickItemGrabResult::ready() is emitted when the grab has been completed.

Use targetSize to specify the size of the target image. By default, the result will have the same size as item.

If the grab could not be initiated, the function returns null.

Note
This function will render the item to an offscreen surface and copy that surface from the GPU's memory into the CPU's memory, which can be quite costly. For "live" preview, use \l {QtQuick::Item::layer.enabled} {layers} or ShaderEffectSource.
See also
QQuickWindow::grabWindow()

Grabs the item into an in-memory image.

The grab happens asynchronously and the JavaScript function callback is invoked when the grab is completed. The callback takes one argument, which is the result of the grab operation; an \l ItemGrabResult object.

Use targetSize to specify the size of the target image. By default, the result will have the same size as the item.

If the grab could not be initiated, the function returns false.

The following snippet shows how to grab an item and store the results in a file:

Rectangle {
id: sourceRectangle
width: 100
height: 100
focus: true
gradient: Gradient {
GradientStop { position: 0; color: "steelblue" }
GradientStop { position: 1; color: "black" }
}
Keys.onSpacePressed: {
sourceRectangle.grabToImage(function(result) {
result.saveToFile("something.png")
})
}
}

The following snippet shows how to grab an item and use the results in another image element:

Image {
id: image
}
Keys.onSpacePressed: {
sourceRectangle.grabToImage(function(result) {
image.source = result.url
}, Qt.size(50, 50))
}
Note
This function will render the item to an offscreen surface and copy that surface from the GPU's memory into the CPU's memory, which can be quite costly. For "live" preview, use \l {QtQuick::Item::layer.enabled} {layers} or ShaderEffectSource.

Only visible from QML.

Definition at line 330 of file qquickitemgrabresult.cpp.

◆ grabTouchPoints()

void QQuickItem::grabTouchPoints ( const QList< int > & ids)
Deprecated
Use QPointerEvent::setExclusiveGrabber(). Grabs the touch points specified by ids.

These touch points will be owned by the item until they are released. Alternatively, the grab can be stolen by a filtering item like Flickable. Use setKeepTouchGrab() to prevent the grab from being stolen.

Deprecated
Use QPointerEvent::setExclusiveGrabber(). Grabs the touch points specified by ids.

These touch points will be owned by the item until they are released. Alternatively, the grab can be stolen by a filtering item like Flickable. Use setKeepTouchGrab() to prevent the grab from being stolen.

Definition at line 8569 of file qquickitem.cpp.

◆ hasActiveFocus()

bool QQuickItem::hasActiveFocus ( ) const

Definition at line 7800 of file qquickitem.cpp.

◆ hasFocus()

bool QQuickItem::hasFocus ( ) const

Definition at line 7894 of file qquickitem.cpp.

◆ height()

qreal QQuickItem::height ( ) const

Definition at line 7524 of file qquickitem.cpp.

◆ heightChanged

void QQuickItem::heightChanged ( )
signal

◆ heightValid()

bool QQuickItem::heightValid ( ) const
protected

Returns whether the height property has been set explicitly.

Definition at line 7678 of file qquickitem.cpp.

◆ hoverEnterEvent()

void QQuickItem::hoverEnterEvent ( QHoverEvent * event)
protectedvirtual

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 in QQuickMouseArea, QQuickRangeSlider, QQuickSpinBox, QQuickText, QQuickTextEdit, QWaylandMouseTracker, and QWaylandQuickItem.

Definition at line 4283 of file qquickitem.cpp.

◆ hoverLeaveEvent()

void QQuickItem::hoverLeaveEvent ( QHoverEvent * event)
protectedvirtual

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 in QQuickMenuBar, QQuickMouseArea, QQuickRangeSlider, QQuickSpinBox, QQuickSplitView, QQuickText, QQuickTextEdit, QWaylandMouseTracker, and QWaylandQuickItem.

Definition at line 4311 of file qquickitem.cpp.

◆ hoverMoveEvent()

void QQuickItem::hoverMoveEvent ( QHoverEvent * event)
protectedvirtual

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 in QQuickMouseArea, QQuickRangeSlider, QQuickSpinBox, QQuickSplitView, QQuickText, QQuickTextEdit, QWaylandMouseTracker, and QWaylandQuickItem.

Definition at line 4297 of file qquickitem.cpp.

◆ implicitHeight()

qreal QQuickItem::implicitHeight ( ) const

Definition at line 7578 of file qquickitem.cpp.

◆ implicitHeightChanged

void QQuickItem::implicitHeightChanged ( )
signal

◆ implicitWidth()

qreal QQuickItem::implicitWidth ( ) const

Returns the width of the item that is implied by other properties that determine the content.

Definition at line 7369 of file qquickitem.cpp.

◆ implicitWidthChanged

void QQuickItem::implicitWidthChanged ( )
signal

◆ isAncestorOf()

bool QQuickItem::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).

Since
5.7
See also
parentItem()

Definition at line 8044 of file qquickitem.cpp.

◆ isComponentComplete()

bool QQuickItem::isComponentComplete ( ) const
protected

Returns true if construction of the QML component is complete; otherwise returns false.

It is often desirable to delay some processing until the component is completed.

See also
componentComplete()

Definition at line 3230 of file qquickitem.cpp.

◆ isEnabled()

bool QQuickItem::isEnabled ( ) const

Definition at line 6578 of file qquickitem.cpp.

◆ isFocusScope()

bool QQuickItem::isFocusScope ( ) const

Returns true if this item is a focus scope, and false otherwise.

Definition at line 7970 of file qquickitem.cpp.

◆ isTextureProvider()

bool QQuickItem::isTextureProvider ( ) const
virtual

Returns true if this item is a texture provider.

The default implementation returns false.

This function can be called from any thread.

Reimplemented in QQuick3DViewport, QQuickCanvasItem, QQuickFramebufferObject, QQuickImage, QQuickPaintedItem, QQuickRhiItem, QQuickShaderEffectSource, and QWaylandQuickItem.

Definition at line 9221 of file qquickitem.cpp.

◆ isUnderMouse()

bool QQuickItem::isUnderMouse ( ) const

Definition at line 8129 of file qquickitem.cpp.

◆ isVisible()

bool QQuickItem::isVisible ( ) const

Definition at line 6511 of file qquickitem.cpp.

◆ itemChange()

void QQuickItem::itemChange ( ItemChange change,
const ItemChangeData & value )
protectedvirtual

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 in QDeclarativeGeoMap, QQuick3DViewport, QQuickAbstractButton, QQuickAnimatedSprite, QQuickBasePositioner, QQuickBasicBusyIndicator, QQuickBasicProgressBar, QQuickCanvasItem, QQuickComboBox, QQuickContainer, QQuickControl, QQuickFolderBreadcrumbBar, QQuickFusionBusyIndicator, QQuickIconImage, QQuickImageBase, QQuickItemGroup, QQuickLabel, QQuickLayout, QQuickLayoutItemProxy, QQuickLoader, QQuickMaterialBusyIndicator, QQuickMaterialProgressBar, QQuickMaterialRipple, QQuickMenuBar, QQuickMouseArea, QQuickMultiEffect, QQuickOverlay, QQuickPaintedItem, QQuickParticlePainter, QQuickPinchArea, QQuickPopupItem, QQuickRectangularShadow, QQuickRepeater, QQuickShaderEffect, QQuickShaderEffectSource, QQuickShape, QQuickSpinBox, QQuickStackLayout, QQuickStyleItem, QQuickText, QQuickTextArea, QQuickTextEdit, QQuickTextField, QQuickTextInput, QQuickTumblerView, QQuickUniversalBusyIndicator, QQuickUniversalProgressBar, QQuickVideoOutput, and QQuickWindowContainer.

Definition at line 5793 of file qquickitem.cpp.

◆ itemTransform()

QTransform QQuickItem::itemTransform ( QQuickItem * other,
bool * ok ) 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)

Maps the point (x, y) or rect (x, y, width, height), which is in item's coordinate system, to this item's coordinate system, and returns a \l point or \l rect matching the mapped coordinate.

\input item.qdocinc mapping

If item is a null value, this maps the point or rect from the coordinate system of the \l{Scene Coordinates}{scene}.

The versions accepting point and rect are since Qt 5.15.

Definition at line 4767 of file qquickitem.cpp.

◆ keepMouseGrab()

bool QQuickItem::keepMouseGrab ( ) const

Returns whether mouse input should exclusively remain with this item.

See also
setKeepMouseGrab(), QEvent::accept(), QEvent::ignore()

Definition at line 8532 of file qquickitem.cpp.

◆ keepTouchGrab()

bool QQuickItem::keepTouchGrab ( ) const

Returns whether the touch points grabbed by this item should exclusively remain with this item.

See also
setKeepTouchGrab(), keepMouseGrab(), QEvent::accept(), QEvent::ignore()

Definition at line 8602 of file qquickitem.cpp.

◆ keyPressEvent()

void QQuickItem::keyPressEvent ( QKeyEvent * event)
protectedvirtual

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

The event information is provided by the event parameter.

\input item.qdocinc accepting-events

Reimplemented in QQuickAbstractButton, QQuickComboBox, QQuickDial, QQuickFolderBreadcrumbBar, QQuickGridView, QQuickListView, QQuickMenuBar, QQuickMenuBarItem, QQuickPopupItem, QQuickRangeSlider, QQuickScrollView, QQuickSlider, QQuickSpinBox, QQuickTableView, QQuickTextEdit, QQuickTextInput, QQuickTreeView, QQuickTumbler, and QWaylandQuickItem.

Definition at line 4103 of file qquickitem.cpp.

◆ keyReleaseEvent()

void QQuickItem::keyReleaseEvent ( QKeyEvent * event)
protectedvirtual

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

The event information is provided by the event parameter.

\input item.qdocinc accepting-events

Reimplemented in QQuickAbstractButton, QQuickComboBox, QQuickDial, QQuickFileDialogDelegate, QQuickMenuBar, QQuickMenuBarItem, QQuickPopupItem, QQuickRangeSlider, QQuickSlider, QQuickSpinBox, QQuickTextEdit, and QWaylandQuickItem.

Definition at line 4115 of file qquickitem.cpp.

◆ mapFromItem() [1/4]

QPointF QQuickItem::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.

\input item.qdocinc mapping

If item is \nullptr, this maps point from the coordinate system of the scene.

See also
{Concepts - Visual Coordinates in Qt Quick}

Definition at line 8901 of file qquickitem.cpp.

◆ mapFromItem() [2/4]

QRectF QQuickItem::mapFromItem ( const QQuickItem * item,
const QRectF & rect ) const

Definition at line 10102 of file qquickitem.cpp.

◆ mapFromItem() [3/4]

QPointF QQuickItem::mapFromItem ( const QQuickItem * item,
qreal x,
qreal y )

Definition at line 10098 of file qquickitem.cpp.

◆ mapFromItem() [4/4]

QRectF QQuickItem::mapFromItem ( const QQuickItem * item,
qreal x,
qreal y,
qreal width,
qreal height ) const

Definition at line 10106 of file qquickitem.cpp.

◆ mapFromScene()

QPointF QQuickItem::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.

\input item.qdocinc mapping

See also
{Concepts - Visual Coordinates in Qt Quick}

Definition at line 8923 of file qquickitem.cpp.

◆ mapRectFromItem()

QRectF QQuickItem::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.

\input item.qdocinc mapping

If item is \nullptr, this maps rect from the coordinate system of the scene.

See also
{Concepts - Visual Coordinates in Qt Quick}

Definition at line 8985 of file qquickitem.cpp.

◆ mapRectFromScene()

QRectF QQuickItem::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.

\input item.qdocinc mapping

See also
{Concepts - Visual Coordinates in Qt Quick}

Definition at line 9002 of file qquickitem.cpp.

◆ mapRectToItem()

QRectF QQuickItem::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.

\input item.qdocinc mapping

If item is \nullptr, this maps rect to the coordinate system of the scene.

See also
{Concepts - Visual Coordinates in Qt Quick}

Definition at line 8865 of file qquickitem.cpp.

◆ mapRectToScene()

QRectF QQuickItem::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.

\input item.qdocinc mapping

See also
{Concepts - Visual Coordinates in Qt Quick}

Definition at line 8883 of file qquickitem.cpp.

◆ mapToItem() [1/4]

QPointF QQuickItem::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.

\input item.qdocinc mapping

If item is \nullptr, this maps point to the coordinate system of the scene.

See also
{Concepts - Visual Coordinates in Qt Quick}

Definition at line 8794 of file qquickitem.cpp.

◆ mapToItem() [2/4]

QRectF QQuickItem::mapToItem ( const QQuickItem * item,
const QRectF & rect ) const

Definition at line 10114 of file qquickitem.cpp.

◆ mapToItem() [3/4]

QPointF QQuickItem::mapToItem ( const QQuickItem * item,
qreal x,
qreal y )

Definition at line 10110 of file qquickitem.cpp.

◆ mapToItem() [4/4]

QRectF QQuickItem::mapToItem ( const QQuickItem * item,
qreal x,
qreal y,
qreal width,
qreal height ) const

Definition at line 10118 of file qquickitem.cpp.

◆ mapToScene()

QPointF QQuickItem::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.

\input item.qdocinc mapping

See also
{Concepts - Visual Coordinates in Qt Quick}

Definition at line 8817 of file qquickitem.cpp.

◆ mouseDoubleClickEvent()

void QQuickItem::mouseDoubleClickEvent ( QMouseEvent * event)
protectedvirtual

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 in QQuickAbstractButton, QQuickMouseArea, QQuickPopupItem, QQuickTextArea, QQuickTextEdit, QQuickTextField, and QQuickTextInput.

Definition at line 4225 of file qquickitem.cpp.

◆ mouseMoveEvent()

void QQuickItem::mouseMoveEvent ( QMouseEvent * event)
protectedvirtual

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 in QQuickControl, QQuickFlickable, QQuickMouseArea, QQuickMultiPointTouchArea, QQuickOverlay, QQuickPathView, QQuickPopupItem, QQuickSwipeDelegate, QQuickSwitch, QQuickSwitchDelegate, QQuickTextArea, QQuickTextEdit, QQuickTextField, QQuickTextInput, QWaylandMouseTracker, and QWaylandQuickItem.

Definition at line 4197 of file qquickitem.cpp.

◆ mousePressEvent()

void QQuickItem::mousePressEvent ( QMouseEvent * event)
protectedvirtual

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 in QDeclarativeGeoMapCopyrightNotice, QQuickAbstractButton, QQuickControl, QQuickDial, QQuickFlickable, QQuickMouseArea, QQuickMultiPointTouchArea, QQuickOverlay, QQuickPathView, QQuickPopupItem, QQuickRangeSlider, QQuickScrollBar, QQuickSlider, QQuickSwipeDelegate, QQuickText, QQuickTextArea, QQuickTextEdit, QQuickTextField, QQuickTextInput, QQuickTreeViewDelegate, and QWaylandQuickItem.

Definition at line 4181 of file qquickitem.cpp.

◆ mouseReleaseEvent()

void QQuickItem::mouseReleaseEvent ( QMouseEvent * event)
protectedvirtual

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 in QDeclarativeGeoMapCopyrightNotice, QQuickControl, QQuickFlickable, QQuickMouseArea, QQuickMultiPointTouchArea, QQuickOverlay, QQuickPathView, QQuickPopupItem, QQuickSwipeDelegate, QQuickText, QQuickTextArea, QQuickTextEdit, QQuickTextField, QQuickTextInput, and QWaylandQuickItem.

Definition at line 4213 of file qquickitem.cpp.

◆ mouseUngrabEvent()

void QQuickItem::mouseUngrabEvent ( )
protectedvirtual

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

Reimplemented in QQuickControl, QQuickFlickable, QQuickMouseArea, QQuickMultiPointTouchArea, QQuickPathView, QQuickPopupItem, QQuickSwipeDelegate, and QQuickTextInput.

Definition at line 4234 of file qquickitem.cpp.

◆ opacity()

qreal QQuickItem::opacity ( ) const

Definition at line 6425 of file qquickitem.cpp.

◆ opacityChanged

void QQuickItem::opacityChanged ( )
signal

◆ parentChanged

void QQuickItem::parentChanged ( QQuickItem * )
signal

◆ parentItem()

QQuickItem * QQuickItem::parentItem ( ) const

Definition at line 2724 of file qquickitem.cpp.

◆ polish()

void QQuickItem::polish ( )

Schedules a polish event for this item.

When the scene graph processes the request, it will call updatePolish() on this item.

See also
updatePolish(), QQuickTest::qIsPolishScheduled(), ensurePolished()

Definition at line 4604 of file qquickitem.cpp.

◆ position()

QPointF QQuickItem::position ( ) const

Definition at line 7206 of file qquickitem.cpp.

◆ Q_REVISION() [1/13]

QQuickItem::Q_REVISION ( 2 ,
1  )

◆ Q_REVISION [2/13]

Q_REVISION(6, 7) void focusPolicyChanged(Qt QQuickItem::Q_REVISION ( 2 ,
1  )
signal

◆ Q_REVISION [3/13]

QQuickItem::Q_REVISION ( 2 ,
1  )
signal

◆ Q_REVISION [4/13]

QQuickItem::Q_REVISION ( 2 ,
11  )
signal

◆ Q_REVISION() [5/13]

QQuickItem::Q_REVISION ( 2 ,
4  ) const &

◆ Q_REVISION() [6/13]

QQuickItem::Q_REVISION ( 2 ,
7  ) const &

◆ Q_REVISION() [7/13]

QQuickItem::Q_REVISION ( 2 ,
7  )

◆ Q_REVISION() [8/13]

QQuickItem::Q_REVISION ( 2 ,
7  ) const &

◆ Q_REVISION() [9/13]

QQuickItem::Q_REVISION ( 2 ,
7  )

◆ Q_REVISION [10/13]

QQuickItem::Q_REVISION ( 6 ,
0  )
signal

◆ Q_REVISION [11/13]

QQuickItem::Q_REVISION ( 6 ,
0  )
signal

◆ Q_REVISION() [12/13]

QQuickItem::Q_REVISION ( 6 ,
3  ) const

◆ Q_REVISION() [13/13]

QQuickItem::Q_REVISION ( 6 ,
3  )

◆ releaseResources()

void QQuickItem::releaseResources ( )
protectedvirtual

This function is called when an item should release graphics resources which are not already managed by the nodes returned from QQuickItem::updatePaintNode().

This happens when the item is about to be removed from the window it was previously rendering to. The item is guaranteed to have a \l {QQuickItem::window()}{window} when the function is called.

The function is called on the GUI thread and the state of the rendering thread, when it is used, is unknown. Objects should not be deleted directly, but instead scheduled for cleanup using QQuickWindow::scheduleRenderJob().

See also
{Graphics Resource Handling}

Reimplemented in QQuick3DViewport, QQuickCanvasItem, QQuickFramebufferObject, QQuickImage, QQuickPaintedItem, QQuickRhiItem, QQuickShaderEffectSource, QQuickVideoOutput, and QQuickWindowContainer.

Definition at line 4002 of file qquickitem.cpp.

◆ resetAntialiasing()

void QQuickItem::resetAntialiasing ( )

Definition at line 7073 of file qquickitem.cpp.

◆ resetHeight()

void QQuickItem::resetHeight ( )

Definition at line 7555 of file qquickitem.cpp.

◆ resetWidth()

void QQuickItem::resetWidth ( )

Definition at line 7347 of file qquickitem.cpp.

◆ rotation()

qreal QQuickItem::rotation ( ) const

Definition at line 6194 of file qquickitem.cpp.

◆ rotationChanged

void QQuickItem::rotationChanged ( )
signal

◆ scale()

qreal QQuickItem::scale ( ) const

Definition at line 6294 of file qquickitem.cpp.

◆ scaleChanged

void QQuickItem::scaleChanged ( )
signal

◆ scopedFocusItem()

QQuickItem * QQuickItem::scopedFocusItem ( ) const

If this item is a focus scope, this returns the item in its focus chain that currently has focus.

Returns \nullptr if this item is not a focus scope.

Definition at line 7981 of file qquickitem.cpp.

◆ setAcceptedMouseButtons()

void QQuickItem::setAcceptedMouseButtons ( Qt::MouseButtons buttons)

Sets the mouse buttons accepted by this item to buttons.

Note
In Qt 5, calling setAcceptedMouseButtons() implicitly caused an item to receive touch events as well as mouse events; but it was recommended to call setAcceptTouchEvents() to subscribe for them. In Qt 6, it is necessary to call setAcceptTouchEvents() to continue to receive them.

Definition at line 8082 of file qquickitem.cpp.

◆ setAcceptHoverEvents()

void QQuickItem::setAcceptHoverEvents ( bool enabled)

If enabled is true, this sets the item to accept hover events; otherwise, hover events are not accepted by this item.

See also
acceptHoverEvents()

Definition at line 8165 of file qquickitem.cpp.

◆ setAcceptTouchEvents()

void QQuickItem::setAcceptTouchEvents ( bool enabled)

If enabled is true, this sets the item to accept touch events; otherwise, touch events are not accepted by this item.

Since
5.10
See also
acceptTouchEvents()

Definition at line 8200 of file qquickitem.cpp.

◆ setActiveFocusOnTab()

void QQuickItem::setActiveFocusOnTab ( bool activeFocusOnTab)

Definition at line 7010 of file qquickitem.cpp.

◆ setAntialiasing()

void QQuickItem::setAntialiasing ( bool aa)

Definition at line 7053 of file qquickitem.cpp.

◆ setBaselineOffset()

void QQuickItem::setBaselineOffset ( qreal offset)

Definition at line 4554 of file qquickitem.cpp.

◆ setClip()

void QQuickItem::setClip ( bool c)

Definition at line 3860 of file qquickitem.cpp.

◆ setContainmentMask()

void QQuickItem::setContainmentMask ( QObject * mask)

Definition at line 8742 of file qquickitem.cpp.

◆ setEnabled()

void QQuickItem::setEnabled ( bool e)

Definition at line 6584 of file qquickitem.cpp.

◆ setFiltersChildMouseEvents()

void QQuickItem::setFiltersChildMouseEvents ( bool filter)

Sets whether pointer events intended for this item's children should be filtered through this item.

If filter is true, childMouseEventFilter() will be called when a pointer event is triggered for a child item.

See also
filtersChildMouseEvents()

Definition at line 8120 of file qquickitem.cpp.

◆ setFlag()

void QQuickItem::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.

These provide various hints for the item; for example, the ItemClipsChildrenToShape flag indicates that all children of this item should be clipped to fit within the item area.

Definition at line 7113 of file qquickitem.cpp.

◆ setFlags()

void QQuickItem::setFlags ( Flags flags)

Enables the specified flags for this item.

See also
setFlag()

Definition at line 7146 of file qquickitem.cpp.

◆ setFocus() [1/2]

void QQuickItem::setFocus ( bool focus,
Qt::FocusReason reason )

Definition at line 7905 of file qquickitem.cpp.

◆ setFocus() [2/2]

void QQuickItem::setFocus ( bool focus)

Definition at line 7900 of file qquickitem.cpp.

◆ setFocusPolicy()

void QQuickItem::setFocusPolicy ( Qt::FocusPolicy policy)

Sets the focus policy of this item to policy.

See also
focusPolicy()

Definition at line 8025 of file qquickitem.cpp.

◆ setHeight()

void QQuickItem::setHeight ( qreal h)

Definition at line 7530 of file qquickitem.cpp.

◆ setImplicitHeight()

void QQuickItem::setImplicitHeight ( qreal h)

Definition at line 7589 of file qquickitem.cpp.

◆ setImplicitSize()

void QQuickItem::setImplicitSize ( qreal w,
qreal h )
protected

Definition at line 7623 of file qquickitem.cpp.

◆ setImplicitWidth()

void QQuickItem::setImplicitWidth ( qreal w)
\qmlproperty real QtQuick::Item::implicitWidth
\qmlproperty real QtQuick::Item::implicitHeight

Defines the preferred width or height of the Item.

If \l width or \l height is not specified, an item's effective size will be
determined by its \l implicitWidth or \l implicitHeight.

However, if an item is the child of a \l {Qt Quick Layouts}{layout}, the
layout will determine the item's preferred size using its implicit size.
In such a scenario, the explicit \l width or \l height will be ignored.

The default implicit size for most items is 0x0, however some items have an inherent
implicit size which cannot be overridden, for example, \l [QML] Image and \l [QML] Text.

Setting the implicit size is useful for defining components that have a preferred size
based on their content, for example:

\qml

Label.qml import QtQuick 2.0

Item { property alias icon: image.source property alias label: text.text implicitWidth: text.implicitWidth + image.implicitWidth implicitHeight: Math.max(text.implicitHeight, image.implicitHeight) Image { id: image } Text { id: text wrapMode: Text.Wrap anchors.left: image.right; anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter } } \endqml

Note
Using implicitWidth of \l [QML] Text or \l [QML] TextEdit and setting the width explicitly incurs a performance penalty as the text must be laid out twice.
\property QQuickItem::implicitWidth
\property QQuickItem::implicitHeight

Defines the preferred width or height of the Item.

If \l width or \l height is not specified, an item's effective size will be
determined by its \l implicitWidth or \l implicitHeight.

However, if an item is the child of a \l {Qt Quick Layouts}{layout}, the
layout will determine the item's preferred size using its implicit size.
In such a scenario, the explicit \l width or \l height will be ignored.

The default implicit size for most items is 0x0, however some items have an inherent
implicit size which cannot be overridden, for example, \l [QML] Image and \l [QML] Text.

Setting the implicit size is useful for defining components that have a preferred size
based on their content, for example:

\qml

Label.qml import QtQuick 2.0

Item { property alias icon: image.source property alias label: text.text implicitWidth: text.implicitWidth + image.implicitWidth implicitHeight: Math.max(text.implicitHeight, image.implicitHeight) Image { id: image } Text { id: text wrapMode: Text.Wrap anchors.left: image.right; anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter } } \endqml

Note
Using implicitWidth of \l [QML] Text or \l [QML] TextEdit and setting the width explicitly incurs a performance penalty as the text must be laid out twice.

Definition at line 7462 of file qquickitem.cpp.

◆ setKeepMouseGrab()

void QQuickItem::setKeepMouseGrab ( bool keep)

Sets whether the mouse input should remain exclusively with this item.

This is useful for items that wish to grab and keep mouse interaction following a predefined gesture. For example, an item that is interested in horizontal mouse movement may set keepMouseGrab to true once a threshold has been exceeded. Once keepMouseGrab has been set to true, filtering items will not react to mouse events.

If keep is false, a filtering item may steal the grab. For example, \l Flickable may attempt to steal a mouse grab if it detects that the user has begun to move the viewport.

See also
keepMouseGrab()

Definition at line 8554 of file qquickitem.cpp.

◆ setKeepTouchGrab()

void QQuickItem::setKeepTouchGrab ( bool keep)

Sets whether the touch points grabbed by this item should remain exclusively with this item.

This is useful for items that wish to grab and keep specific touch points following a predefined gesture. For example, an item that is interested in horizontal touch point movement may set setKeepTouchGrab to true once a threshold has been exceeded. Once setKeepTouchGrab has been set to true, filtering items will not react to the relevant touch points.

If keep is false, a filtering item may steal the grab. For example, \l Flickable may attempt to steal a touch point grab if it detects that the user has begun to move the viewport.

See also
keepTouchGrab(), setKeepMouseGrab()

Definition at line 8625 of file qquickitem.cpp.

◆ setOpacity()

void QQuickItem::setOpacity ( qreal newOpacity)

Definition at line 6431 of file qquickitem.cpp.

◆ setParentItem()

void QQuickItem::setParentItem ( QQuickItem * parent)

Definition at line 2730 of file qquickitem.cpp.

◆ setPosition()

void QQuickItem::setPosition ( const QPointF & pos)

Definition at line 7268 of file qquickitem.cpp.

◆ setRotation()

void QQuickItem::setRotation ( qreal r)

Definition at line 6200 of file qquickitem.cpp.

◆ setScale()

void QQuickItem::setScale ( qreal s)

Definition at line 6300 of file qquickitem.cpp.

◆ setSize()

void QQuickItem::setSize ( const QSizeF & size)
Since
5.10

Sets the size of the item to size. This methods preserves any existing binding on width and height; thus any change that triggers the binding to execute again will override the set values.

See also
size, setWidth, setHeight

Definition at line 7709 of file qquickitem.cpp.

◆ setSmooth()

void QQuickItem::setSmooth ( bool smooth)

Definition at line 6954 of file qquickitem.cpp.

◆ setState()

void QQuickItem::setState ( const QString & state)

Definition at line 5300 of file qquickitem.cpp.

◆ setTransformOrigin()

void QQuickItem::setTransformOrigin ( TransformOrigin origin)

Definition at line 5920 of file qquickitem.cpp.

◆ setTransformOriginPoint()

void QQuickItem::setTransformOriginPoint ( const QPointF & point)

Definition at line 5950 of file qquickitem.cpp.

◆ setVisible()

void QQuickItem::setVisible ( bool v)

Definition at line 6531 of file qquickitem.cpp.

◆ setWidth()

void QQuickItem::setWidth ( qreal w)

Definition at line 7325 of file qquickitem.cpp.

◆ setX()

void QQuickItem::setX ( qreal v)

Definition at line 7212 of file qquickitem.cpp.

◆ setY()

void QQuickItem::setY ( qreal v)

Definition at line 7242 of file qquickitem.cpp.

◆ setZ()

void QQuickItem::setZ ( qreal v)

Definition at line 6120 of file qquickitem.cpp.

◆ size()

QSizeF QQuickItem::size ( ) const
Since
5.10

Returns the size of the item.

See also
setSize, width, height

Definition at line 7692 of file qquickitem.cpp.

◆ smooth()

bool QQuickItem::smooth ( ) const

Definition at line 6949 of file qquickitem.cpp.

◆ smoothChanged

void QQuickItem::smoothChanged ( bool )
signal

◆ stackAfter()

void QQuickItem::stackAfter ( const QQuickItem * sibling)

Moves the specified sibling item to the index after this item within the list of children.

The order of children affects both the visual stacking order and tab focus navigation order.

Assuming the z values of both items are the same, this will cause sibling to be rendered below this item.

If both items have activeFocusOnTab set to true, this will also cause the tab focus order to change, with sibling receiving focus before this item.

The given sibling must be a sibling of this item; that is, they must have the same immediate \l parent.

See also
{Concepts - Visual Parent in Qt Quick}

Definition at line 2935 of file qquickitem.cpp.

◆ stackBefore()

void QQuickItem::stackBefore ( const QQuickItem * sibling)

Moves the specified sibling item to the index before this item within the list of children.

The order of children affects both the visual stacking order and tab focus navigation order.

Assuming the z values of both items are the same, this will cause sibling to be rendered above this item.

If both items have activeFocusOnTab set to true, this will also cause the tab focus order to change, with sibling receiving focus after this item.

The given sibling must be a sibling of this item; that is, they must have the same immediate \l parent.

See also
{Concepts - Visual Parent in Qt Quick}

Definition at line 2890 of file qquickitem.cpp.

◆ state()

QString QQuickItem::state ( ) const

\qmlproperty string QtQuick::Item::state

This property holds the name of the current state of the item.

If the item is in its default state, that is, no explicit state has been set, then this property holds an empty string. Likewise, you can return an item to its default state by setting this property to an empty string.

See also
{Qt Quick States}

This property holds the name of the current state of the item.

If the item is in its default state, that is, no explicit state has been set, then this property holds an empty string. Likewise, you can return an item to its default state by setting this property to an empty string.

See also
{Qt Quick States}

Definition at line 5294 of file qquickitem.cpp.

◆ stateChanged

void QQuickItem::stateChanged ( const QString & state)
signal

◆ textureProvider()

QSGTextureProvider * QQuickItem::textureProvider ( ) const
virtual

Returns the texture provider for an item.

The default implementation returns \nullptr.

This function may only be called on the rendering thread.

Reimplemented in QQuick3DViewport, QQuickCanvasItem, QQuickFramebufferObject, QQuickImage, QQuickPaintedItem, QQuickRhiItem, QQuickShaderEffectSource, and QWaylandQuickItem.

Definition at line 9241 of file qquickitem.cpp.

◆ touchEvent()

void QQuickItem::touchEvent ( QTouchEvent * event)
protectedvirtual

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

The event information is provided by the event parameter.

\input item.qdocinc accepting-events

Reimplemented in QQuickFlickable, QQuickMultiPointTouchArea, QQuickPinchArea, QQuickSwipeDelegate, and QWaylandQuickItem.

Definition at line 4269 of file qquickitem.cpp.

◆ touchUngrabEvent()

void QQuickItem::touchUngrabEvent ( )
protectedvirtual

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

Reimplemented in QQuickMouseArea, QQuickMultiPointTouchArea, and QWaylandQuickItem.

Definition at line 4243 of file qquickitem.cpp.

◆ transform()

QQmlListProperty< QQuickTransform > QQuickItem::transform ( )

◆ transformOrigin()

QQuickItem::TransformOrigin QQuickItem::transformOrigin ( ) const

Definition at line 5914 of file qquickitem.cpp.

◆ transformOriginChanged

void QQuickItem::transformOriginChanged ( TransformOrigin )
signal

◆ transformOriginPoint()

QPointF QQuickItem::transformOriginPoint ( ) const

Definition at line 5939 of file qquickitem.cpp.

◆ ungrabMouse()

void QQuickItem::ungrabMouse ( )
Deprecated
Use QPointerEvent::setExclusiveGrabber().

Releases the mouse grab following a call to grabMouse().

Note that this function should only be called when the item wants to stop handling further events. There is no need to call this function after a release or cancel event since no future events will be received in any case. No move or release events will be delivered after this function was called.

Deprecated
Use QPointerEvent::setExclusiveGrabber().

Releases the mouse grab following a call to grabMouse().

Note that this function should only be called when the item wants to stop handling further events. There is no need to call this function after a release or cancel event since no future events will be received in any case. No move or release events will be delivered after this function was called.

Definition at line 8509 of file qquickitem.cpp.

◆ ungrabTouchPoints()

void QQuickItem::ungrabTouchPoints ( )
Deprecated
Use QEventPoint::setExclusiveGrabber() instead. Ungrabs the touch points owned by this item.
Deprecated
Use QEventPoint::setExclusiveGrabber() instead. Ungrabs the touch points owned by this item.

Definition at line 8587 of file qquickitem.cpp.

◆ update

void QQuickItem::update ( )
slot

Schedules a call to updatePaintNode() for this item.

The call to QQuickItem::updatePaintNode() will always happen if the item is showing in a QQuickWindow.

Only items which specify QQuickItem::ItemHasContents are allowed to call QQuickItem::update().

Definition at line 4584 of file qquickitem.cpp.

◆ updatePaintNode()

QSGNode * QQuickItem::updatePaintNode ( QSGNode * oldNode,
UpdatePaintNodeData * updatePaintNodeData )
protectedvirtual

Called on the render thread when it is time to sync the state of the item with the scene graph.

The function is called as a result of QQuickItem::update(), if the user has set the QQuickItem::ItemHasContents flag on the item.

The function should return the root of the scene graph subtree for this item. Most implementations will return a single QSGGeometryNode containing the visual representation of this item. oldNode is the node that was returned the last time the function was called. updatePaintNodeData provides a pointer to the QSGTransformNode associated with this QQuickItem.

QSGNode *MyItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
{
QSGSimpleRectNode *n = static_cast<QSGSimpleRectNode *>(node);
if (!n) {
n->setColor(Qt::red);
}
return n;
}
virtual QRectF boundingRect() const
Returns the extents of the item in its own coordinate system: a rectangle from {0,...
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
The QSGSimpleRectNode class is a convenience class for drawing solid filled rectangles using scenegra...
void setRect(const QRectF &rect)
Sets the rectangle of this rect node to rect.
@ red
Definition qnamespace.h:36
GLfloat n
[4]

The main thread is blocked while this function is executed so it is safe to read values from the QQuickItem instance and other objects in the main thread.

If no call to QQuickItem::updatePaintNode() result in actual scene graph changes, like QSGNode::markDirty() or adding and removing nodes, then the underlying implementation may decide to not render the scene again as the visual outcome is identical.

Warning
It is crucial that graphics operations and interaction with the scene graph happens exclusively on the render thread, primarily during the QQuickItem::updatePaintNode() call. The best rule of thumb is to only use classes with the "QSG" prefix inside the QQuickItem::updatePaintNode() function.
This function is called on the render thread. This means any QObjects or thread local storage that is created will have affinity to the render thread, so apply caution when doing anything other than rendering in this function. Similarly for signals, these will be emitted on the render thread and will thus often be delivered via queued connections.
Note
All classes with QSG prefix should be used solely on the scene graph's rendering thread. See \l {Scene Graph and Rendering} for more information.
See also
QSGMaterial, QSGGeometryNode, QSGGeometry, QSGFlatColorMaterial, QSGTextureMaterial, QSGNode::markDirty(), {Graphics Resource Handling}

Reimplemented in QDeclarativeGeoMap, QDeclarativeGeoMapItemBase, QQuick3DViewport, QQuickAnimatedSprite, QQuickBasicBusyIndicator, QQuickBasicProgressBar, QQuickBorderImage, QQuickCanvasItem, QQuickFramebufferObject, QQuickImage, QQuickImageParticle, QQuickItemParticle, QQuickMaterialBusyIndicator, QQuickMaterialProgressBar, QQuickMaterialRipple, QQuickMouseArea, QQuickMultiPointTouchArea, QQuickNinePatchImage, QQuickPaddedRectangle, QQuickPaintedItem, QQuickRectangle, QQuickRhiItem, QQuickShaderEffect, QQuickShaderEffectSource, QQuickShape, QQuickSpriteSequence, QQuickStyleItem, QQuickText, QQuickTextArea, QQuickTextEdit, QQuickTextField, QQuickTextInput, QQuickUniversalBusyIndicator, QQuickUniversalProgressBar, QQuickVideoOutput, and QWaylandQuickItem.

Definition at line 3973 of file qquickitem.cpp.

◆ updatePolish()

void QQuickItem::updatePolish ( )
protectedvirtual

This function should perform any layout as required for this item.

When polish() is called, the scene graph schedules a polish event for this item. When the scene graph is ready to render this item, it calls updatePolish() to do any item layout as required before it renders the next frame.

See also
ensurePolished()

Reimplemented in QDeclarativeCircleMapItem, QDeclarativeGeoMapQuickItem, QDeclarativePolygonMapItem, QDeclarativePolylineMapItem, QDeclarativeRectangleMapItem, QGfxSourceProxyME, QQuickBasePositioner, QQuickCanvasItem, QQuickDialogButtonBox, QQuickFlipable, QQuickItemView, QQuickLayout, QQuickMonthGrid, QQuickPathView, QQuickPopupItem, QQuickShape, QQuickStyleItem, QQuickTabBar, QQuickText, QQuickTextEdit, QQuickTextInput, QQuickTumbler, and QQuickWindowContainer.

Definition at line 4021 of file qquickitem.cpp.

◆ viewportItem()

QQuickItem * QQuickItem::viewportItem ( ) const

If the \l ItemObservesViewport flag is set, returns the nearest parent with the \l ItemIsViewport flag.

Returns the window's contentItem if the flag is not set, or if no other viewport item is found.

Returns \nullptr only if there is no viewport item and this item is not shown in a window.

See also
clipRect()

Definition at line 5871 of file qquickitem.cpp.

◆ visibleChanged

void QQuickItem::visibleChanged ( )
signal

◆ visibleChildrenChanged

void QQuickItem::visibleChildrenChanged ( )
signal

◆ width()

qreal QQuickItem::width ( ) const

Definition at line 7319 of file qquickitem.cpp.

◆ widthChanged

void QQuickItem::widthChanged ( )
signal

◆ widthValid()

bool QQuickItem::widthValid ( ) const
protected

Returns whether the width property has been set explicitly.

Definition at line 7496 of file qquickitem.cpp.

◆ window()

QQuickWindow * QQuickItem::window ( ) const

Returns the window in which this item is rendered.

The item does not have a window until it has been assigned into a scene. The \l windowChanged() signal provides a notification both when the item is entered into a scene and when it is removed from a scene.

Definition at line 2974 of file qquickitem.cpp.

◆ x()

qreal QQuickItem::x ( ) const

Definition at line 7191 of file qquickitem.cpp.

◆ xChanged

void QQuickItem::xChanged ( )
signal

◆ y()

qreal QQuickItem::y ( ) const

Definition at line 7197 of file qquickitem.cpp.

◆ yChanged

void QQuickItem::yChanged ( )
signal

◆ z()

qreal QQuickItem::z ( ) const

Definition at line 6114 of file qquickitem.cpp.

◆ zChanged

void QQuickItem::zChanged ( )
signal

Friends And Related Symbol Documentation

◆ operator<<

Q_QUICK_EXPORT QDebug operator<< ( QDebug debug,
QQuickItem * item )
friend

◆ QAccessibleQuickItem

friend class QAccessibleQuickItem
friend

Definition at line 480 of file qquickitem.h.

◆ QQuickAccessibleAttached

friend class QQuickAccessibleAttached
friend

Definition at line 481 of file qquickitem.h.

◆ QQuickAnchorChanges

friend class QQuickAnchorChanges
friend

Definition at line 482 of file qquickitem.h.

◆ QQuickDeliveryAgentPrivate

friend class QQuickDeliveryAgentPrivate
friend

Definition at line 478 of file qquickitem.h.

◆ QSGRenderer

friend class QSGRenderer
friend

Definition at line 479 of file qquickitem.h.

Member Data Documentation

◆ const

qreal y QQuickItem::const

Definition at line 349 of file qquickitem.h.

◆ targetSize

const QSize& QQuickItem::targetSize = QSize())

Definition at line 308 of file qquickitem.h.

Property Documentation

◆ antialiasing

bool QQuickItem::antialiasing
readwrite

\qmlproperty bool QtQuick::Item::antialiasing

Used by visual elements to decide if the item should use antialiasing or not. In some cases items with antialiasing require more memory and are potentially slower to render (see \l {Antialiasing} for more details).

The default is false, but may be overridden by derived elements.

Specifies whether the item is antialiased or not

Used by visual elements to decide if the item should use antialiasing or not. In some cases items with antialiasing require more memory and are potentially slower to render (see \l {Antialiasing} for more details).

The default is false, but may be overridden by derived elements.

Definition at line 113 of file qquickitem.h.

◆ containmentMask

QObject * QQuickItem::containmentMask
readwrite

\qmlproperty QObject* QtQuick::Item::containmentMask

Since
5.11 This property holds an optional mask for the Item to be used in the \l contains() method. Its main use is currently to determine whether a \l {QPointerEvent}{pointer event} has landed into the item or not.

By default the contains() method will return true for any point within the Item's bounding box. containmentMask allows for more fine-grained control. For example, if a custom C++ QQuickItem subclass with a specialized contains() method is used as containmentMask:

Item { id: item; containmentMask: AnotherItem { id: anotherItem } }
Definition lalr.h:84
QObject * containmentMask
\qmlproperty QObject* QtQuick::Item::containmentMask
Definition qquickitem.h:116
GLenum GLuint id
[7]
QGraphicsItem * item

{item}'s contains method would then return true only if {anotherItem}'s contains() implementation returns true.

A \l Shape can be used as a mask, to make an item react to \l {QPointerEvent}{pointer events} only within a non-rectangular region:

\table \row

  • Rectangle {
    width: 90; height: 100
    color: hoverHandler.hovered ? "wheat" : "lightgray"
    containmentMask: shape
    HoverHandler { id: hoverHandler }
    Shape {
    id: shape
    containsMode: Shape.FillContains
    ShapePath {
    fillColor: "lightsteelblue"
    startX: 10; startY: 20
    PathArc {
    x: 10; y: 80
    radiusX: 40; radiusY: 40
    useLargeArc: true
    }
    PathLine {
    x: 10; y: 20
    }
    }
    }
    }
    \endtable

It is also possible to define the contains method in QML. For example, to create a circular item that only responds to events within its actual bounds:

\table \row

  • Rectangle {
    id: circle
    width: 100; height: width
    radius: width / 2
    color: tapHandler.pressed ? "tomato" : hoverHandler.hovered ? "darkgray" : "lightgray"
    TapHandler { id: tapHandler }
    HoverHandler { id: hoverHandler }
    containmentMask: QtObject {
    property alias radius: circle.radius
    function contains(point: point) : bool {
    return (Math.pow(point.x - radius, 2) + Math.pow(point.y - radius, 2)) < Math.pow(radius, 2)
    }
    }
    }
    \endtable
See also
{Qt Quick Examples - Shapes}
Since
5.11 This property holds an optional mask to be used in the contains() method, which is mainly used for hit-testing each \l QPointerEvent.

By default, \l contains() will return true for any point within the Item's bounding box. But any QQuickItem, or any QObject that implements a function of the form

Q_INVOKABLE bool contains(const QPointF &point) const;
\inmodule QtCore\reentrant
Definition qpoint.h:217
virtual Q_INVOKABLE bool contains(const QPointF &point) const
\qmlmethod bool QtQuick::Item::contains(point point)
#define Q_INVOKABLE

can be used as a mask, to defer hit-testing to that object.

Note
contains() is called frequently during event delivery. Deferring hit-testing to another object slows it down somewhat. containmentMask() can cause performance problems if that object's contains() method is not efficient. If you implement a custom QQuickItem subclass, you can alternatively override contains().
See also
contains()

Definition at line 116 of file qquickitem.h.

◆ enabled

bool QQuickItem::enabled
readwrite

\qmlproperty bool QtQuick::Item::enabled

This property holds whether the item receives mouse and keyboard events. By default this is true.

Setting this property directly affects the enabled value of child items. When set to false, the enabled values of all child items also become false. When set to true, the enabled values of child items are returned to true, unless they have explicitly been set to false.

Setting this property to false automatically causes \l activeFocus to be set to false, and this item will no longer receive keyboard events.

See also
visible

This property holds whether the item receives mouse and keyboard events. By default this is true.

Setting this property directly affects the enabled value of child items. When set to false, the enabled values of all child items also become false. When set to true, the enabled values of child items are returned to true, unless they have explicitly been set to false.

Setting this property to false automatically causes \l activeFocus to be set to false, and this item will longer receive keyboard events.

Note
Hover events are enabled separately by \l setAcceptHoverEvents(). Thus, a disabled item can continue to receive hover events, even when this property is false. This makes it possible to show informational feedback (such as \l ToolTip) even when an interactive item is disabled. The same is also true for any \l {HoverHandler}{HoverHandlers} added as children of the item. A HoverHandler can, however, be \l {PointerHandler::enabled}{disabled} explicitly, or for example be bound to the enabled state of the item.
See also
visible

Definition at line 79 of file qquickitem.h.

◆ focusPolicy

Qt::FocusPolicy QQuickItem::focusPolicy
readwrite

\qmlproperty enumeration QtQuick::Item::focusPolicy

Since
6.7

This property determines the way the item accepts focus.

\value Qt.TabFocus The item accepts focus by tabbing. \value Qt.ClickFocus The item accepts focus by clicking. \value Qt.StrongFocus The item accepts focus by both tabbing and clicking. \value Qt.WheelFocus The item accepts focus by tabbing, clicking, and using the mouse wheel. \value Qt.NoFocus The item does not accept focus.

Note
This property was a member of the \l[QML]{Control} QML type in Qt 6.6 and earlier.
Since
6.7

This property determines the way the item accepts focus.

Definition at line 104 of file qquickitem.h.

◆ height

qreal QQuickItem::height
readwrite

This property holds the height of this item.

Definition at line 76 of file qquickitem.h.

◆ implicitHeight

qreal QQuickItem::implicitHeight
readwrite

Definition at line 115 of file qquickitem.h.

◆ implicitWidth

qreal QQuickItem::implicitWidth
readwrite

Definition at line 114 of file qquickitem.h.

◆ opacity

qreal QQuickItem::opacity
readwrite

\qmlproperty real QtQuick::Item::opacity

This property holds the opacity of the item. Opacity is specified as a number between 0.0 (fully transparent) and 1.0 (fully opaque). The default value is 1.0.

When this property is set, the specified opacity is also applied individually to child items. This may have an unintended effect in some circumstances. For example in the second set of rectangles below, the red rectangle has specified an opacity of 0.5, which affects the opacity of its blue child rectangle even though the child has not specified an opacity.

\table \row

  • \qml Item { Rectangle { color: "red" width: 100; height: 100 Rectangle { color: "blue" x: 50; y: 50; width: 100; height: 100 } } } \endqml \row
  • \qml Item { Rectangle { opacity: 0.5 color: "red" width: 100; height: 100 Rectangle { color: "blue" x: 50; y: 50; width: 100; height: 100 } } } \endqml \endtable

Changing an item's opacity does not affect whether the item receives user input events. (In contrast, setting \l visible property to false stops mouse events, and setting the \l enabled property to false stops mouse and keyboard events, and also removes active focus from the item.)

See also
visible

This property holds the opacity of the item. Opacity is specified as a number between 0.0 (fully transparent) and 1.0 (fully opaque). The default value is 1.0.

When this property is set, the specified opacity is also applied individually to child items. This may have an unintended effect in some circumstances. For example in the second set of rectangles below, the red rectangle has specified an opacity of 0.5, which affects the opacity of its blue child rectangle even though the child has not specified an opacity.

Values outside the range of 0 to 1 will be clamped.

\table \row

  • \qml Item { Rectangle { color: "red" width: 100; height: 100 Rectangle { color: "blue" x: 50; y: 50; width: 100; height: 100 } } } \endqml \row
  • \qml Item { Rectangle { opacity: 0.5 color: "red" width: 100; height: 100 Rectangle { color: "blue" x: 50; y: 50; width: 100; height: 100 } } } \endqml \endtable

Changing an item's opacity does not affect whether the item receives user input events. (In contrast, setting \l visible property to false stops mouse events, and setting the \l enabled property to false stops mouse and keyboard events, and also removes active focus from the item.)

See also
visible

Definition at line 78 of file qquickitem.h.

◆ parent

QQuickItem * QQuickItem::parent
readwrite

\qmlproperty Item QtQuick::Item::parent This property holds the visual parent of the item.

Note
The concept of the {visual parent} differs from that of the {QObject parent}. An item's visual parent may not necessarily be the same as its object parent. See \l {Concepts - Visual Parent in Qt Quick} for more details.

This property holds the visual parent of the item.

Note
The concept of the {visual parent} differs from that of the {QObject parent}. An item's visual parent may not necessarily be the same as its object parent. See \l {Concepts - Visual Parent in Qt Quick} for more details.
The notification signal for this property gets emitted during destruction of the visual parent. C++ signal handlers cannot assume that items in the visual parent hierarchy are still fully constructed. Use \l qobject_cast to verify that items in the parent hierarchy can be used safely as the expected type.

Definition at line 67 of file qquickitem.h.

◆ rotation

qreal QQuickItem::rotation
readwrite

\qmlproperty real QtQuick::Item::rotation This property holds the rotation of the item in degrees clockwise around its transformOrigin.

The default value is 0 degrees (that is, no rotation).

\table \row

  • \qml Rectangle { color: "blue" width: 100; height: 100 Rectangle { color: "red" x: 25; y: 25; width: 50; height: 50 rotation: 30 } } \endqml \endtable
See also
Transform, Rotation

This property holds the rotation of the item in degrees clockwise around its transformOrigin.

The default value is 0 degrees (that is, no rotation).

\table \row

  • \qml Rectangle { color: "blue" width: 100; height: 100 Rectangle { color: "red" x: 25; y: 25; width: 50; height: 50 rotation: 30 } } \endqml \endtable
See also
Transform, Rotation

Definition at line 106 of file qquickitem.h.

◆ scale

qreal QQuickItem::scale
readwrite

\qmlproperty real QtQuick::Item::scale This property holds the scale factor for this item.

A scale of less than 1.0 causes the item to be rendered at a smaller size, and a scale greater than 1.0 renders the item at a larger size. A negative scale causes the item to be mirrored when rendered.

The default value is 1.0.

Scaling is applied from the transformOrigin.

\table \row

  • \qml import QtQuick 2.0

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

Rectangle { color: "green" width: 25; height: 25 }

Rectangle { color: "red" x: 25; y: 25; width: 50; height: 50 scale: 1.4 transformOrigin: Item.TopLeft } } \endqml \endtable

See also
Transform, Scale

This property holds the scale factor for this item.

A scale of less than 1.0 causes the item to be rendered at a smaller size, and a scale greater than 1.0 renders the item at a larger size. A negative scale causes the item to be mirrored when rendered.

The default value is 1.0.

Scaling is applied from the transformOrigin.

\table \row

  • \qml import QtQuick 2.0

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

Rectangle { color: "green" width: 25; height: 25 }

Rectangle { color: "red" x: 25; y: 25; width: 50; height: 50 scale: 1.4 } } \endqml \endtable

See also
Transform, Scale

Definition at line 107 of file qquickitem.h.

◆ smooth

bool QQuickItem::smooth
readwrite

\qmlproperty bool QtQuick::Item::smooth

Primarily used in image based items to decide if the item should use smooth sampling or not. Smooth sampling is performed using linear interpolation, while non-smooth is performed using nearest neighbor.

In Qt Quick 2.0, this property has minimal impact on performance.

By default, this property is set to true.

Specifies whether the item is smoothed or not

Primarily used in image based items to decide if the item should use smooth sampling or not. Smooth sampling is performed using linear interpolation, while non-smooth is performed using nearest neighbor.

In Qt Quick 2.0, this property has minimal impact on performance.

By default, this property is set to true.

Definition at line 112 of file qquickitem.h.

◆ transform

QQmlListProperty< QQuickTransform > QQuickItem::transform
read

\qmlproperty list<Transform> QtQuick::Item::transform This property holds the list of transformations to apply.

For more information see \l Transform.

Definition at line 110 of file qquickitem.h.

◆ transformOrigin

TransformOrigin QQuickItem::transformOrigin
readwrite

\qmlproperty enumeration QtQuick::Item::transformOrigin This property holds the origin point around which scale and rotation transform.

Nine transform origins are available, as shown in the image below. The default transform origin is Item.Center.

This example rotates an image around its bottom-right corner. \qml Image { source: "myimage.png" transformOrigin: Item.BottomRight rotation: 45 } \endqml

To set an arbitrary transform origin point use the \l Scale or \l Rotation transform types with \l transform.

This property holds the origin point around which scale and rotation transform.

Nine transform origins are available, as shown in the image below. The default transform origin is Item.Center.

Definition at line 108 of file qquickitem.h.

◆ transformOriginPoint

QPointF QQuickItem::transformOriginPoint
read

Definition at line 109 of file qquickitem.h.

◆ visible

bool QQuickItem::visible
readwrite

\qmlproperty bool QtQuick::Item::visible

This property holds whether the item is visible. By default this is true.

Setting this property directly affects the visible value of child items. When set to false, the visible values of all child items also become false. When set to true, the visible values of child items are returned to true, unless they have explicitly been set to false.

(Because of this flow-on behavior, using the visible property may not have the intended effect if a property binding should only respond to explicit property changes. In such cases it may be better to use the \l opacity property instead.)

If this property is set to false, the item will no longer receive mouse events, but will continue to receive key events and will retain the keyboard \l focus if it has been set. (In contrast, setting the \l enabled property to false stops both mouse and keyboard events, and also removes focus from the item.)

Note
This property's value is only affected by changes to this property or the parent's visible property. It does not change, for example, if this item moves off-screen, or if the \l opacity changes to 0.
See also
opacity, enabled

This property holds whether the item is visible. By default this is true.

Setting this property directly affects the visible value of child items. When set to false, the visible values of all child items also become false. When set to true, the visible values of child items are returned to true, unless they have explicitly been set to false.

(Because of this flow-on behavior, using the visible property may not have the intended effect if a property binding should only respond to explicit property changes. In such cases it may be better to use the \l opacity property instead.)

If this property is set to false, the item will no longer receive mouse events, but will continue to receive key events and will retain the keyboard \l focus if it has been set. (In contrast, setting the \l enabled property to false stops both mouse and keyboard events, and also removes focus from the item.)

Note
This property's value is only affected by changes to this property or the parent's visible property. It does not change, for example, if this item moves off-screen, or if the \l opacity changes to 0. However, for historical reasons, this property is true after the item's construction, even if the item hasn't been added to a scene yet. Changing or reading this property of an item that has not been added to a scene might not produce the expected results.
The notification signal for this property gets emitted during destruction of the visual parent. C++ signal handlers cannot assume that items in the visual parent hierarchy are still fully constructed. Use \l qobject_cast to verify that items in the parent hierarchy can be used safely as the expected type.
See also
opacity, enabled

Definition at line 80 of file qquickitem.h.

◆ width

qreal QQuickItem::width
readwrite

This property holds the width of this item.

Definition at line 75 of file qquickitem.h.

◆ x

qreal QQuickItem::x
readwrite

\qmlproperty real QtQuick::Item::x \qmlproperty real QtQuick::Item::y \qmlproperty real QtQuick::Item::width \qmlproperty real QtQuick::Item::height

Defines the item's position and size. The default value is 0.

The (x,y) position is relative to the \l parent.

\qml Item { x: 100; y: 100; width: 100; height: 100 } \endqml

Defines the item's x position relative to its parent.

Definition at line 72 of file qquickitem.h.

◆ y

qreal QQuickItem::y
readwrite

Defines the item's y position relative to its parent.

Definition at line 73 of file qquickitem.h.

◆ z

qreal QQuickItem::z
readwrite

\qmlproperty real QtQuick::Item::z

Sets the stacking order of sibling items. By default the stacking order is 0.

Items with a higher stacking value are drawn on top of siblings with a lower stacking order. Items with the same stacking value are drawn bottom up in the order they appear. Items with a negative stacking value are drawn under their parent's content.

The following example shows the various effects of stacking order.

\table \row

  • Same z - later children above earlier children: \qml Item { Rectangle { color: "red" width: 100; height: 100 } Rectangle { color: "blue" x: 50; y: 50; width: 100; height: 100 } } \endqml \row
  • Higher z on top: \qml Item { Rectangle { z: 1 color: "red" width: 100; height: 100 } Rectangle { color: "blue" x: 50; y: 50; width: 100; height: 100 } } \endqml \row
  • Same z - children above parents: \qml Item { Rectangle { color: "red" width: 100; height: 100 Rectangle { color: "blue" x: 50; y: 50; width: 100; height: 100 } } } \endqml \row
  • Lower z below: \qml Item { Rectangle { color: "red" width: 100; height: 100 Rectangle { z: -1 color: "blue" x: 50; y: 50; width: 100; height: 100 } } } \endqml \endtable

Sets the stacking order of sibling items. By default the stacking order is 0.

Items with a higher stacking value are drawn on top of siblings with a lower stacking order. Items with the same stacking value are drawn bottom up in the order they appear. Items with a negative stacking value are drawn under their parent's content.

The following example shows the various effects of stacking order.

\table \row

  • Same z - later children above earlier children: \qml Item { Rectangle { color: "red" width: 100; height: 100 } Rectangle { color: "blue" x: 50; y: 50; width: 100; height: 100 } } \endqml \row
  • Higher z on top: \qml Item { Rectangle { z: 1 color: "red" width: 100; height: 100 } Rectangle { color: "blue" x: 50; y: 50; width: 100; height: 100 } } \endqml \row
  • Same z - children above parents: \qml Item { Rectangle { color: "red" width: 100; height: 100 Rectangle { color: "blue" x: 50; y: 50; width: 100; height: 100 } } } \endqml \row
  • Lower z below: \qml Item { Rectangle { color: "red" width: 100; height: 100 Rectangle { z: -1 color: "blue" x: 50; y: 50; width: 100; height: 100 } } } \endqml \endtable

Definition at line 74 of file qquickitem.h.


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