QQuickItem Class

Detailed Description

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, anchoring and key handling support.

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

Custom Scene Graph Items

All visual QML items are rendered using the scene graph, the default implementation of which is a low-level, high-performance rendering stack, closely tied to accelerated graphics APIs, such as OpenGL, Vulkan, Metal, or Direct 3D. It is possible for subclasses of QQuickItem to add their own custom content into the scene graph by setting the QQuickItem::ItemHasContents flag and reimplementing the QQuickItem::updatePaintNode() function.

It is crucial that graphics operations and interaction with the scene graph happens exclusively on the rendering thread, primarily during the updatePaintNode() call. The best rule of thumb is to only use classes with the "QSG" prefix inside the QQuickItem::updatePaintNode() function.

All classes with QSG prefix should be used solely on the scene graph's rendering thread. See Scene Graph and Rendering for more information.

Graphics Resource Handling

The preferred way to handle cleanup of graphics resources used in the scene graph, is to rely on the automatic cleanup of nodes. A QSGNode returned from QQuickItem::updatePaintNode() is automatically deleted on the right thread at the right time. Trees of QSGNode instances are managed through the use of QSGNode::OwnedByParent, which is set by default. So, for the majority of custom scene graph items, no extra work will be required.

Implementations that store graphics resources outside the node tree, such as an item implementing QQuickItem::textureProvider(), will need to take care in cleaning it up correctly depending on how the item is used in QML. The situations to handle are:

  • The scene graph is invalidated; This can happen, depending on the platform and QQuickWindow configuration, when the window is hidden using QQuickWindow::hide(), or when it is closed. If the item class implements a slot named invalidateSceneGraph(), this slot will be called on the rendering thread while the GUI thread is blocked. This is equivalent to connecting to QQuickWindow::sceneGraphInvalidated(). When rendering through OpenGL, the OpenGL context of this item's window will be bound when this slot is called. The only exception is if the native OpenGL has been destroyed outside Qt's control, for instance through EGL_CONTEXT_LOST.

  • The item is removed from the scene; If an item is taken out of the scene, for instance because it's parent was set to null or an item in another window, the QQuickItem::releaseResources() will be called on the GUI thread. QQuickWindow::scheduleRenderJob() should be used to schedule cleanup of rendering resources.

  • The item is deleted; When the destructor if an item runs, it should delete any graphics resources it has. If neither of the two conditions above were already met, the item will be part of a window and it is possible to use QQuickWindow::scheduleRenderJob() to have them cleaned up. If an implementation ignores the call to QQuickItem::releaseResources(), the item will in many cases no longer have access to a QQuickWindow and thus no means of scheduling cleanup.

When scheduling cleanup of graphics resources using QQuickWindow::scheduleRenderJob(), one should use either QQuickWindow::BeforeSynchronizingStage or QQuickWindow::AfterSynchronizingStage. The synchronization stage is where the scene graph is changed as a result of changes to the QML tree. If cleanup is scheduled at any other time, it may result in other parts of the scene graph referencing the newly deleted objects as these parts have not been updated.

Use of QObject::deleteLater() to clean up graphics resources is strongly discouraged as this will make the delete operation run at an arbitrary time and it is unknown if there will be an OpenGL context bound when the deletion takes place.

Custom QPainter Items

The QQuickItem provides a subclass, QQuickPaintedItem, which allows the users to render content using QPainter.

Using QQuickPaintedItem uses an indirect 2D surface to render its content, using software rasterization, so the rendering is a two-step operation. First rasterize the surface, then draw the surface. Using scene graph API directly is always significantly faster.

Behavior Animations

If your Item uses the Behavior type to define animations for property changes, you should always use either QObject::setProperty(), QQmlProperty(), or QMetaProperty::write() when you need to modify those properties from C++. This ensures that the QML engine knows about the property change. Otherwise, the engine won't be able to carry out your requested animation. Note that these functions incur a slight performance penalty. For more details, see Accessing Members of a QML Object Type from C++.

See Also

Member Type Documentation

 

enum QQuickItem::Flag

flags QQuickItem::Flags

This enum type is used to specify various item properties.

Constant

Value

Description

QQuickItem::ItemClipsChildrenToShape

0x01

Indicates this item should visually clip its children so that they are rendered only within the boundaries of this item.

QQuickItem::ItemAcceptsInputMethod

0x02

Indicates the item supports text input methods.

QQuickItem::ItemIsFocusScope

0x04

Indicates the item is a focus scope. See Keyboard Focus in Qt Quick for more information.

QQuickItem::ItemHasContents

0x08

Indicates the item has visual content and should be rendered by the scene graph.

QQuickItem::ItemAcceptsDrops

0x10

Indicates the item accepts drag and drop events.

QQuickItem::ItemIsViewport

0x20

Indicates that the item defines a viewport for its children.

QQuickItem::ItemObservesViewport

0x40

Indicates that the item wishes to know the viewport bounds when any ancestor has the ItemIsViewport flag set.

The Flags type is a typedef for QFlags<Flag>. It stores an OR combination of Flag values.

See Also

See also setFlag(), setFlags(), flags()

enum QQuickItem::ItemChange

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

Constant

Value

Description

QQuickItem::ItemChildAddedChange

0

A child was added. ItemChangeData::item contains the added child.

QQuickItem::ItemChildRemovedChange

1

A child was removed. ItemChangeData::item contains the removed child.

QQuickItem::ItemSceneChange

2

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.

QQuickItem::ItemVisibleHasChanged

3

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

QQuickItem::ItemParentHasChanged

4

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

QQuickItem::ItemOpacityHasChanged

5

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

QQuickItem::ItemActiveFocusHasChanged

6

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

QQuickItem::ItemRotationHasChanged

7

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

QQuickItem::ItemDevicePixelRatioHasChanged

9

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

QQuickItem::ItemAntialiasingHasChanged

8

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

QQuickItem::ItemEnabledHasChanged

10

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

enum QQuickItem::TransformOrigin

Controls the point about which simple transforms like scale apply.

Constant

Value

Description

QQuickItem::TopLeft

0

The top-left corner of the item.

QQuickItem::Top

1

The center point of the top of the item.

QQuickItem::TopRight

2

The top-right corner of the item.

QQuickItem::Left

3

The left most point of the vertical middle.

QQuickItem::Center

4

The center of the item.

QQuickItem::Right

5

The right most point of the vertical middle.

QQuickItem::BottomLeft

6

The bottom-left corner of the item.

QQuickItem::Bottom

7

The center point of the bottom of the item.

QQuickItem::BottomRight

8

The bottom-right corner of the item.

See Also

Property Documentation

 

implicitHeight : qreal

implicitWidth : qreal

Defines the preferred width or height of the Item.

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

However, if an item is the child of a layout, the layout will determine the item's preferred size using its implicit size. In such a scenario, the explicit width or 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, Image and Text.

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

 
Sélectionnez
// 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
    }
}

Using implicitWidth of Text or TextEdit and setting the width explicitly incurs a performance penalty as the text must be laid out twice.

[read-only] activeFocus : const bool

This read-only property indicates whether the item has active focus.

If activeFocus is true, either this item is the one that currently receives keyboard input, or it is a FocusScope ancestor of the item that currently receives keyboard input.

Usually, activeFocus is gained by setting focus on an item and its enclosing FocusScope objects. In the following example, the input and focusScope objects will have active focus, while the root rectangle object will not.

 
Sélectionnez
import QtQuick 2.0

Rectangle {
    width: 100; height: 100

    FocusScope {
        focus: true

        TextInput {
            id: input
            focus: true
        }
    }
}

Access functions:

  • bool hasActiveFocus() const

Notifier signal:

  • void activeFocusChanged(bool)

See Also

activeFocusOnTab : bool

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

Access functions:

  • bool activeFocusOnTab() const

  • void setActiveFocusOnTab(bool)

Notifier signal:

  • void activeFocusOnTabChanged(bool)

antialiasing : bool

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 Antialiasing for more details).

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

Access functions:

  • bool antialiasing() const

  • void setAntialiasing(bool)

  • void resetAntialiasing()

Notifier signal:

  • void antialiasingChanged(bool)

baselineOffset : qreal

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

The baseline of a 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.

Access functions:

  • baselineOffset() const

  • void setBaselineOffset(qreal)

Notifier signal:

  • void baselineOffsetChanged(qreal)

[read-only] childrenRect : const QRectF

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:

 
Sélectionnez
Item {
    x: 50
    y: 100

    // prints: QRectF(-10, -20, 30, 40)
    Component.onCompleted: print(childrenRect)

    Item {
        x: -10
        y: -20
        width: 30
        height: 40
    }
}

Access functions:

  • childrenRect()

Notifier signal:

  • void childrenRectChanged(const QRectF &)

clip : bool

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.

Clipping can affect rendering performance. See Clipping for more information.

For the sake of QML, setting clip to true also sets the ItemIsViewport flag, which sometimes acts as an optimization: child items that have the ItemObservesViewport flag may forego creating scene graph nodes that fall outside the viewport. But the ItemIsViewport flag can also be set independently.

Access functions:

  • bool clip() const

  • void setClip(bool)

Notifier signal:

  • void clipChanged(bool)

[since 5.11] containmentMask : QObject*

This property holds an optional mask to be used in the contains() method, which is mainly used for hit-testing each QPointerEvent.

By default, 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

 
Sélectionnez
Q_INVOKABLE bool contains(const QPointF &amp;point) const;

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

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

This property was introduced in Qt 5.11.

Access functions:

  • *containmentMask() const

  • void setContainmentMask( *mask)

Notifier signal:

  • void containmentMaskChanged()

See Also

See also contains()

enabled : bool

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 activeFocus to be set to false, and this item will longer receive keyboard events.

Access functions:

  • bool isEnabled() const

  • void setEnabled(bool)

Notifier signal:

  • void enabledChanged()

See Also

See also visible

focus : bool

This property holds whether the item has focus within the enclosing FocusScope. If true, this item will gain active focus when the enclosing FocusScope gains active focus.

In the following example, input will be given active focus when scope gains active focus:

 
Sélectionnez
import QtQuick 2.0

Rectangle {
    width: 100; height: 100

    FocusScope {
        id: scope

        TextInput {
            id: input
            focus: true
        }
    }
}

For the purposes of this property, the scene as a whole is assumed to act like a focus scope. On a practical level, that means the following QML will give active focus to input on startup.

 
Sélectionnez
Rectangle {
    width: 100; height: 100

    TextInput {
          id: input
          focus: true
    }
}

Access functions:

  • bool hasFocus() const

  • void setFocus(bool)

  • void setFocus(bool focus, reason)

Notifier signal:

  • void focusChanged(bool)

See Also

[bindable] height : qreal

This property supports QProperty bindings.

This property holds the height of this item.

opacity : qreal

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.

Image non disponible
 
Sélectionnez
Item {
    Rectangle {
        color: "red"
        width: 100; height: 100
        Rectangle {
            color: "blue"
            x: 50; y: 50; width: 100; height: 100
        }
    }
}
Image non disponible
 
Sélectionnez
Item {
    Rectangle {
        opacity: 0.5
        color: "red"
        width: 100; height: 100
        Rectangle {
            color: "blue"
            x: 50; y: 50; width: 100; height: 100
        }
    }
}

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

Access functions:

  • opacity() const

  • void setOpacity(qreal)

Notifier signal:

  • void opacityChanged()

See Also

See also visible

parent : QQuickItem*

This property holds the visual parent of the item.

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 Concepts - Visual Parent in Qt Quick for more details.

Access functions:

  • *parentItem() const

  • void setParentItem( *parent)

Notifier signal:

  • void parentChanged(QQuickItem *)

rotation : qreal

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

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

Image non disponible
 
Sélectionnez
Rectangle {
    color: "blue"
    width: 100; height: 100
    Rectangle {
        color: "red"
        x: 25; y: 25; width: 50; height: 50
        rotation: 30
    }
}

Access functions:

  • rotation() const

  • void setRotation(qreal)

Notifier signal:

  • void rotationChanged()

See Also

See also Transform, Rotation

scale : qreal

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.

Image non disponible
 
Sélectionnez
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
    }
}

Access functions:

  • scale() const

  • void setScale(qreal)

Notifier signal:

  • void scaleChanged()

See Also

See also Transform, Scale

smooth : bool

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.

Access functions:

  • bool smooth() const

  • void setSmooth(bool)

Notifier signal:

  • void smoothChanged(bool)

state : QString

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.

Access functions:

  • state() const

  • void setState(const QString &)

Notifier signal:

  • void stateChanged(const QString &)

See Also

See also Qt Quick States

transformOrigin : 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.

Image non disponible

Access functions:

  • transformOrigin() const

  • void setTransformOrigin(QQuickItem::TransformOrigin)

Notifier signal:

  • void transformOriginChanged(QQuickItem::TransformOrigin)

visible : bool

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 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 focus if it has been set. (In contrast, setting the enabled property to false stops both mouse and keyboard events, and also removes focus from the item.)

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 opacity changes to 0.

Access functions:

  • bool isVisible() const

  • void setVisible(bool)

Notifier signal:

  • void visibleChanged()

See Also

See also opacity, enabled

[bindable] width : qreal

This property supports QProperty bindings.

This property holds the width of this item.

[bindable] x : qreal

This property supports QProperty bindings.

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

[bindable] y : qreal

This property supports QProperty bindings.

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

z : qreal

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.

Image non disponible

Same z - later children above earlier children:

 
Sélectionnez
Item {
    Rectangle {
        color: "red"
        width: 100; height: 100
    }
    Rectangle {
        color: "blue"
        x: 50; y: 50; width: 100; height: 100
    }
}
Image non disponible

Higher z on top:

 
Sélectionnez
Item {
    Rectangle {
        z: 1
        color: "red"
        width: 100; height: 100
    }
    Rectangle {
        color: "blue"
        x: 50; y: 50; width: 100; height: 100
    }
}
Image non disponible

Same z - children above parents:

 
Sélectionnez
Item {
    Rectangle {
        color: "red"
        width: 100; height: 100
        Rectangle {
            color: "blue"
            x: 50; y: 50; width: 100; height: 100
        }
    }
}
Image non disponible

Lower z below:

 
Sélectionnez
Item {
    Rectangle {
        color: "red"
        width: 100; height: 100
        Rectangle {
            z: -1
            color: "blue"
            x: 50; y: 50; width: 100; height: 100
        }
    }
}

Access functions:

  • z() const

  • void setZ(qreal)

Notifier signal:

  • void zChanged()

Member Function Documentation

 

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

Constructs a QQuickItem with the given parent.

The parent will be used as both the visual parent and the QObject parent.

[override virtual] QQuickItem::~QQuickItem()

Destroys the QQuickItem.

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.

See Also

[since 5.10] 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.

This function was introduced in Qt 5.10.

See Also

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

[virtual] QRectF QQuickItem::boundingRect() const

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

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

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.

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

Returns the children of this item.

[virtual protected] bool QQuickItem::childMouseEventFilter(QQuickItem *item, QEvent *event)

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.

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

[override virtual protected] void QQuickItem::classBegin()

Reimplements: QQmlParserStatus::classBegin().

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

[virtual] QRectF QQuickItem::clipRect() const

Returns the rectangular area within this item that is currently visible in viewportItem(), if there is a viewport and the ItemObservesViewport flag is set; otherwise, the extents of this item in its own coordinate system: a rectangle from 0, 0 to width() and height(). This is the region intended to remain visible if 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 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 boundingRects of all ancestors that have the ItemIsViewport flag set, mapped to the coordinate system of this item.

See Also

See also boundingRect()

[override virtual protected] void QQuickItem::componentComplete()

Reimplements: QQmlParserStatus::componentComplete().

Derived classes should call the base class method before adding their own actions to perform at componentComplete.

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

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 containmentMask() if it is set, or inside the bounding box otherwise.

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

QCursor QQuickItem::cursor() const

Returns the cursor shape for this item.

The mouse cursor will assume this shape when it is over this item, unless an override cursor is set. See the list of predefined cursor objects for a range of useful shapes.

If no cursor shape has been set this returns a cursor with the Qt::ArrowCursor shape, however another cursor shape may be displayed if an overlapping item has a valid cursor.

See Also

See also setCursor(), unsetCursor()

[virtual protected] void QQuickItem::dragEnterEvent(QDragEnterEvent *event)

This event handler can be reimplemented in a subclass to receive drag-enter events for an item. The event information is provided by the event parameter.

Drag and drop events are only provided if the ItemAcceptsDrops flag has been set for this item.

The event is accepted by default, so it is not necessary to explicitly accept the event if you reimplement this function. If you don't accept the event, call event->ignore().

See Also

See also Drag, Drag and Drop

[virtual protected] void QQuickItem::dragLeaveEvent(QDragLeaveEvent *event)

This event handler can be reimplemented in a subclass to receive drag-leave events for an item. The event information is provided by the event parameter.

Drag and drop events are only provided if the ItemAcceptsDrops flag has been set for this item.

The event is accepted by default, so it is not necessary to explicitly accept the event if you reimplement this function. If you don't accept the event, call event->ignore().

See Also

See also Drag, Drag and Drop

[virtual protected] void QQuickItem::dragMoveEvent(QDragMoveEvent *event)

This event handler can be reimplemented in a subclass to receive drag-move events for an item. The event information is provided by the event parameter.

Drag and drop events are only provided if the ItemAcceptsDrops flag has been set for this item.

The event is accepted by default, so it is not necessary to explicitly accept the event if you reimplement this function. If you don't accept the event, call event->ignore().

See Also

See also Drag, Drag and Drop

[virtual protected] void QQuickItem::dropEvent(QDropEvent *event)

This event handler can be reimplemented in a subclass to receive drop events for an item. The event information is provided by the event parameter.

Drag and drop events are only provided if the ItemAcceptsDrops flag has been set for this item.

The event is accepted by default, so it is not necessary to explicitly accept the event if you reimplement this function. If you don't accept the event, call event->ignore().

See Also

See also Drag, Drag and Drop

[since 6.3] void QQuickItem::dumpItemTree() const

Dumps some details about the visual tree of Items starting with this item, recursively.

QObject::dumpObjectTree() dumps a similar tree; but, as explained in Concepts - Visual Parent in Qt Quick, an item's QObject::parent() sometimes differs from its QQuickItem::parentItem(). You can dump both trees to see the difference.

The exact output format may change in future versions of Qt.

This function was introduced in Qt 6.3.

See Also