- class QQuickItem¶
The
QQuickItem
class provides the most basic of all visual items in Qt Quick . More…Inherited by:
QQuickRhiItem
,QQuickPaintedItem
,QQuickFramebufferObject
Synopsis¶
Properties¶
antialiasingᅟ
- Specifies whether the item is antialiased or notsmoothᅟ
- Specifies whether the item is smoothed or not
Methods¶
def
__init__()
def
antialiasing()
def
baselineOffset()
def
childAt()
def
childItems()
def
childrenRect()
def
clip()
def
cursor()
def
dumpItemTree()
def
ensurePolished()
def
flags()
def
focusPolicy()
def
grabMouse()
def
grabToImage()
def
hasActiveFocus()
def
hasFocus()
def
height()
def
heightValid()
def
implicitHeight()
def
implicitWidth()
def
isAncestorOf()
def
isEnabled()
def
isFocusScope()
def
isUnderMouse()
def
isVisible()
def
itemTransform()
def
keepMouseGrab()
def
keepTouchGrab()
def
mapFromGlobal()
def
mapFromItem()
def
mapFromScene()
def
mapRectToItem()
def
mapRectToScene()
def
mapToGlobal()
def
mapToItem()
def
mapToScene()
def
opacity()
def
parentItem()
def
polish()
def
position()
def
resetHeight()
def
resetWidth()
def
rotation()
def
scale()
def
setClip()
def
setCursor()
def
setEnabled()
def
setFlag()
def
setFlags()
def
setFocus()
def
setFocusPolicy()
def
setHeight()
def
setOpacity()
def
setParentItem()
def
setPosition()
def
setRotation()
def
setScale()
def
setSize()
def
setSmooth()
def
setState()
def
setVisible()
def
setWidth()
def
setX()
def
setY()
def
setZ()
def
size()
def
smooth()
def
stackAfter()
def
stackBefore()
def
state()
def
ungrabMouse()
def
unsetCursor()
def
viewportItem()
def
width()
def
widthValid()
def
window()
def
x()
def
y()
def
z()
Virtual methods¶
def
boundingRect()
def
clipRect()
def
contains()
def
dragEnterEvent()
def
dragLeaveEvent()
def
dragMoveEvent()
def
dropEvent()
def
focusInEvent()
def
focusOutEvent()
def
geometryChange()
def
hoverMoveEvent()
def
keyPressEvent()
def
mouseMoveEvent()
def
touchEvent()
def
updatePolish()
def
wheelEvent()
Slots¶
def
update()
Signals¶
def
clipChanged()
def
enabledChanged()
def
focusChanged()
def
heightChanged()
def
opacityChanged()
def
paletteChanged()
def
paletteCreated()
def
parentChanged()
def
scaleChanged()
def
smoothChanged()
def
stateChanged()
def
visibleChanged()
def
widthChanged()
def
windowChanged()
def
xChanged()
def
yChanged()
def
zChanged()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
All visual items in Qt Quick inherit from
QQuickItem
. Although aQQuickItem
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 theItemHasContents
flag and reimplementing theupdatePaintNode()
function.Warning
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 theupdatePaintNode()
function.Note
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 fromupdatePaintNode()
is automatically deleted on the right thread at the right time. Trees ofQSGNode
instances are managed through the use ofOwnedByParent
, 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
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 aslot
namedinvalidateSceneGraph()
, this slot will be called on the rendering thread while the GUI thread is blocked. This is equivalent to connecting tosceneGraphInvalidated()
. 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 throughEGL_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, thereleaseResources()
will be called on the GUI thread.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
scheduleRenderJob()
to have them cleaned up. If an implementation ignores the call toreleaseResources()
, the item will in many cases no longer have access to aQQuickWindow
and thus no means of scheduling cleanup.
When scheduling cleanup of graphics resources using
scheduleRenderJob()
, one should use eitherBeforeSynchronizingStage
orAfterSynchronizingStage
. 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.Note
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.Warning
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
- class Flag¶
(inherits
enum.Flag
) This enum type is used to specify various item properties.Constant
Description
QQuickItem.ItemClipsChildrenToShape
Indicates this item should visually clip its children so that they are rendered only within the boundaries of this item.
QQuickItem.ItemAcceptsInputMethod
Indicates the item supports text input methods.
QQuickItem.ItemIsFocusScope
Indicates the item is a focus scope. See Keyboard Focus in Qt Quick for more information.
QQuickItem.ItemHasContents
Indicates the item has visual content and should be rendered by the scene graph.
QQuickItem.ItemAcceptsDrops
Indicates the item accepts drag and drop events.
QQuickItem.ItemIsViewport
Indicates that the item defines a viewport for its children.
QQuickItem.ItemObservesViewport
Indicates that the item wishes to know the viewport bounds when any ancestor has the ItemIsViewport flag set.
See also
- class ItemChange¶
Used in conjunction with
itemChange()
to notify the item about certain types of changes.Constant
Description
QQuickItem.ItemChildAddedChange
A child was added. ItemChangeData::item contains the added child.
QQuickItem.ItemChildRemovedChange
A child was removed. ItemChangeData::item contains the removed child.
QQuickItem.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.QQuickItem.ItemVisibleHasChanged
The item’s visibility has changed. ItemChangeData::boolValue contains the new visibility.
QQuickItem.ItemParentHasChanged
The item’s parent has changed. ItemChangeData::item contains the new parent.
QQuickItem.ItemOpacityHasChanged
The item’s opacity has changed. ItemChangeData::realValue contains the new opacity.
QQuickItem.ItemActiveFocusHasChanged
The item’s focus has changed. ItemChangeData::boolValue contains whether the item has focus or not.
QQuickItem.ItemRotationHasChanged
The item’s rotation has changed. ItemChangeData::realValue contains the new rotation.
QQuickItem.ItemDevicePixelRatioHasChanged
The device pixel ratio of the screen the item is on has changed. ItemChangedData::realValue contains the new device pixel ratio.
QQuickItem.ItemAntialiasingHasChanged
The antialiasing has changed. The current (boolean) value can be found in
antialiasing
.QQuickItem.ItemEnabledHasChanged
The item’s enabled state has changed. ItemChangeData::boolValue contains the new enabled state. (since Qt 5.10)
- class TransformOrigin¶
Controls the point about which simple transforms like scale apply.
Constant
Description
QQuickItem.TopLeft
The top-left corner of the item.
QQuickItem.Top
The center point of the top of the item.
QQuickItem.TopRight
The top-right corner of the item.
QQuickItem.Left
The left most point of the vertical middle.
QQuickItem.Center
The center of the item.
QQuickItem.Right
The right most point of the vertical middle.
QQuickItem.BottomLeft
The bottom-left corner of the item.
QQuickItem.Bottom
The center point of the bottom of the item.
QQuickItem.BottomRight
The bottom-right corner of the item.
See also
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- property activeFocusᅟ: 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, theinput
andfocusScope
objects will have active focus, while the root rectangle object will not.See also
focus
Keyboard Focus in Qt Quick- Access functions:
- property 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:
- property antialiasingᅟ: bool¶
This property 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:
- property baselineOffsetᅟ: float¶
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:
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 } }
- Access functions:
- property 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.
Note
Clipping can affect rendering performance. See Clipping for more information.
Note
For the sake of QML, setting clip to
true
also sets theItemIsViewport
flag, which sometimes acts as an optimization: child items that have theItemObservesViewport
flag may forego creating scene graph nodes that fall outside the viewport. But theItemIsViewport
flag can also be set independently.- Access functions:
Signal
clipChanged()
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 returntrue
for any point within the Item’s bounding box. But anyQQuickItem
, or any QObject that implements a function of the formQ_INVOKABLE bool contains(const QPointF &point) const;
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’scontains()
method is not efficient. If you implement a customQQuickItem
subclass, you can alternatively overridecontains()
.See also
- Access functions:
- property 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 tofalse
, theenabled
values of all child items also becomefalse
. When set totrue
, theenabled
values of child items are returned totrue
, unless they have explicitly been set tofalse
.Setting this property to
false
automatically causesactiveFocus
to be set tofalse
, and this item will longer receive keyboard events.Note
Hover events are enabled separately by
setAcceptHoverEvents()
. Thus, a disabled item can continue to receive hover events, even when this property isfalse
. This makes it possible to show informational feedback (such as ToolTip) even when an interactive item is disabled. The same is also true for any HoverHandlers added as children of the item. A HoverHandler can, however, be disabled explicitly, or for example be bound to theenabled
state of the item.See also
visible
- Access functions:
- property 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 whenscope
gains active focus: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.See also
activeFocus
Keyboard Focus in Qt Quick- Access functions:
Signal
focusChanged()
- property focusPolicyᅟ: Qt.FocusPolicy¶
This property determines the way the item accepts focus.
- Access functions:
- property heightᅟ: float¶
This property holds the height of this item.
- Access functions:
- property implicitHeightᅟ: float¶
- Access functions:
- property implicitWidthᅟ: float¶
- Access functions:
- property opacityᅟ: float¶
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:: images/declarative-item_opacity1.png|| +—————————————————++ | .. image:: images/declarative-item_opacity2.png|| +—————————————————++
Changing an item’s opacity does not affect whether the item receives user input events. (In contrast, setting
visible
property tofalse
stops mouse events, and setting theenabled
property tofalse
stops mouse and keyboard events, and also removes active focus from the item.)See also
visible
- Access functions:
- property parentᅟ: QQuickItem¶
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 Concepts - Visual Parent in Qt Quick for more details.
Note
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 qobject_cast to verify that items in the parent hierarchy can be used safely as the expected type.
- Access functions:
- property rotationᅟ: float¶
This property holds the rotation of the item in degrees clockwise around its
transformOrigin
.The default value is 0 degrees (that is, no rotation).
- Access functions:
- property scaleᅟ: float¶
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
.- Access functions:
Signal
scaleChanged()
- property smoothᅟ: bool¶
This property 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:
Signal
smoothChanged()
- property stateᅟ: str¶
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
- Access functions:
Signal
stateChanged()
- property transformOriginᅟ: QQuickItem.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
.- Access functions:
- Access functions:
- property 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 tofalse
, thevisible
values of all child items also becomefalse
. When set totrue
, thevisible
values of child items are returned totrue
, unless they have explicitly been set tofalse
.(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 theopacity
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 keyboardfocus
if it has been set. (In contrast, setting theenabled
property tofalse
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 theopacity
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.Note
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 qobject_cast to verify that items in the parent hierarchy can be used safely as the expected type.
See also
opacity
enabled
- Access functions:
- property widthᅟ: float¶
This property holds the width of this item.
- Access functions:
- property xᅟ: float¶
Defines the item’s x position relative to its parent.
- Access functions:
Signal
xChanged()
- property yᅟ: float¶
Defines the item’s y position relative to its parent.
- Access functions:
Signal
yChanged()
- property zᅟ: float¶
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.
Same
z
- later children above earlier children:Higher
z
on top:Same
z
- children above parents:Lower
z
below:- Access functions:
Signal
zChanged()
- __init__([parent=None])¶
- Parameters:
parent –
QQuickItem
Constructs a
QQuickItem
with the givenparent
.The
parent
will be used as both thevisual parent
and the QObject parent.- acceptHoverEvents()¶
- Return type:
bool
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()
andhoverLeaveEvent()
functions.See also
- acceptTouchEvents()¶
- Return type:
bool
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 thetouchEvent()
function.See also
- acceptedMouseButtons()¶
- Return type:
Combination of
MouseButton
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.
- activeFocusChanged(arg__1)¶
- Parameters:
arg__1 – bool
Notification signal of property
activeFocusᅟ
.- activeFocusOnTab()¶
- Return type:
bool
See also
Getter of property
activeFocusOnTabᅟ
.- activeFocusOnTabChanged(arg__1)¶
- Parameters:
arg__1 – bool
Notification signal of property
activeFocusOnTabᅟ
.- antialiasing()¶
- Return type:
bool
See also
Getter of property
antialiasingᅟ
.- antialiasingChanged(arg__1)¶
- Parameters:
arg__1 – bool
Notification signal of property
antialiasingᅟ
.- baselineOffset()¶
- Return type:
float
See also
Getter of property
baselineOffsetᅟ
.- baselineOffsetChanged(arg__1)¶
- Parameters:
arg__1 – float
Notification signal of property
baselineOffsetᅟ
.Returns the extents of the item in its own coordinate system: a rectangle from
0, 0
towidth()
andheight()
.- childAt(x, y)¶
- Parameters:
x – float
y – float
- Return type:
Returns the first visible child item found at point (
x
,y
) within the coordinate system of this item.Returns
None
if there is no such item.- childItems()¶
- Return type:
.list of QQuickItem
Returns the children of this item.
- childMouseEventFilter(arg__1, arg__2)¶
- Parameters:
arg__1 –
QQuickItem
arg__2 –
QEvent
- Return type:
bool
Reimplement this method to filter the pointer events that are received by this item’s children.
This method will only be called if
filtersChildMouseEvents()
istrue
.Return
true
if the specifiedevent
should not be passed on to the specified childitem
, andfalse
otherwise. If you returntrue
, you should also accept or ignore theevent
, to signal if event propagation should stop or continue. Theevent
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/orevent->device()->type()
to handle different event types in different ways.Note
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
- childrenChanged()¶
Getter of property
childrenRectᅟ
.Notification signal of property
childrenRectᅟ
.Getter of property
clipᅟ
.- clipChanged(arg__1)¶
- Parameters:
arg__1 – bool
Notification signal of property
clipᅟ
.Returns the rectangular area within this item that is currently visible in
viewportItem()
, if there is a viewport and theItemObservesViewport
flag is set; otherwise, the extents of this item in its own coordinate system: a rectangle from0, 0
towidth()
andheight()
. This is the region intended to remain visible ifclip
istrue
. It can also be used inupdatePaintNode()
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
boundingRect
s of all ancestors that have theItemIsViewport
flag set, mapped to the coordinate system of this item.See also
- containmentMask()¶
- Return type:
See also
Getter of property
containmentMaskᅟ
.- containmentMaskChanged()¶
Notification signal of property
containmentMaskᅟ
.Returns
true
if this item containspoint
, which is in local coordinates; returnsfalse
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.Note
This method is used for hit-testing each QEventPoint during event delivery, so the implementation should be kept as lightweight as possible.
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
- dragEnterEvent(arg__1)¶
- Parameters:
arg__1 –
QDragEnterEvent
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
Drag
Drag and Drop
- dragLeaveEvent(arg__1)¶
- Parameters:
arg__1 –
QDragLeaveEvent
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
Drag
Drag and Drop
- dragMoveEvent(arg__1)¶
- Parameters:
arg__1 –
QDragMoveEvent
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
Drag
Drag and Drop
- dropEvent(arg__1)¶
- Parameters:
arg__1 –
QDropEvent
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
Drag
Drag and Drop
- dumpItemTree()¶
Dumps some details about the visual tree of Items starting with this item, recursively.
Note
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
parentItem()
. You can dump both trees to see the difference.Note
The exact output format may change in future versions of Qt.
See also
- enabledChanged()¶
Notification signal of property
enabledᅟ
.- ensurePolished()¶
Calls
updatePolish()
This can be useful for items such as Layouts (or Positioners) which delay calculation of their
implicitWidth
andimplicitHeight
until they receive a PolishEvent.Normally, if e.g. a child item is added or removed to a Layout, the implicit size is not immediately calculated (this is an optimization). In some cases it might be desirable to query the implicit size of the layout right after a child item has been added. If this is the case, use this function right before querying the implicit size.
See also
- filtersChildMouseEvents()¶
- Return type:
bool
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.Returns the item flags for this item.
See also
- focusChanged(arg__1)¶
- Parameters:
arg__1 – bool
Notification signal of property
focusᅟ
.- focusInEvent(arg__1)¶
- Parameters:
arg__1 –
QFocusEvent
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.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()
.If you do reimplement this function, you should call the base class implementation.
- focusOutEvent(arg__1)¶
- Parameters:
arg__1 –
QFocusEvent
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.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()
.- focusPolicy()¶
- Return type:
See also
Getter of property
focusPolicyᅟ
.- focusPolicyChanged(arg__1)¶
- Parameters:
arg__1 –
FocusPolicy
Notification signal of property
focusPolicyᅟ
.- 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
focus
.The reason for the focus change will be Qt::OtherFocusReason. Use the overloaded method to specify the focus reason to enable better handling of the focus change.
See also
activeFocus
- forceActiveFocus(reason)
- Parameters:
reason –
FocusReason
This is an overloaded function.
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
focus
.See also
activeFocus
FocusReason
This function is called to handle this item’s changes in geometry from
oldGeometry
tonewGeometry
. If the two geometries are the same, it doesn’t do anything.Derived classes must call the base class method within their implementation.
- grabMouse()¶
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.
Grabs the item into an in-memory image.
The grab happens asynchronously and the signal
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 layers or ShaderEffectSource .
See also
- grabToImage(callback[, targetSize=QSize()])
- grabTouchPoints(ids)¶
- Parameters:
ids – .list of int
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.- hasActiveFocus()¶
- Return type:
bool
Getter of property
activeFocusᅟ
.- hasFocus()¶
- Return type:
bool
Getter of property
focusᅟ
.- height()¶
- Return type:
float
See also
Getter of property
heightᅟ
.- heightChanged()¶
Notification signal of property
heightᅟ
.- heightValid()¶
- Return type:
bool
Returns whether the height property has been set explicitly.
- hoverEnterEvent(event)¶
- Parameters:
event –
QHoverEvent
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.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()
.- hoverLeaveEvent(event)¶
- Parameters:
event –
QHoverEvent
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.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()
.- hoverMoveEvent(event)¶
- Parameters:
event –
QHoverEvent
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.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()
.- implicitHeight()¶
- Return type:
float
See also
Getter of property
implicitHeightᅟ
.- implicitHeightChanged()¶
Notification signal of property
implicitHeightᅟ
.- implicitWidth()¶
- Return type:
float
Returns the width of the item that is implied by other properties that determine the content.
See also
Getter of property
implicitWidthᅟ
.- implicitWidthChanged()¶
Notification signal of property
implicitWidthᅟ
.- inputMethodEvent(arg__1)¶
- Parameters:
arg__1 –
QInputMethodEvent
This event handler can be reimplemented in a subclass to receive input method events for an item. The event information is provided by the
event
parameter.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()
.- inputMethodQuery(query)¶
- Parameters:
query –
InputMethodQuery
- Return type:
object
This method is only relevant for input items.
If this item is an input item, this method should be reimplemented to return the relevant input method flags for the given
query
.See also
- isAncestorOf(child)¶
- Parameters:
child –
QQuickItem
- Return type:
bool
Returns
true
if this item is an ancestor ofchild
(i.e., if this item ischild
's parent, or one ofchild
's parent’s ancestors).See also
- isComponentComplete()¶
- Return type:
bool
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()
- isEnabled()¶
- Return type:
bool
Getter of property
enabledᅟ
.- isFocusScope()¶
- Return type:
bool
Returns true if this item is a focus scope, and false otherwise.
- isTextureProvider()¶
- Return type:
bool
Returns true if this item is a texture provider. The default implementation returns false.
This function can be called from any thread.
- isUnderMouse()¶
- Return type:
bool
- isVisible()¶
- Return type:
bool
Getter of property
visibleᅟ
.- itemTransform(arg__1)¶
- Parameters:
arg__1 –
QQuickItem
- Return type:
PyTuple
- keepMouseGrab()¶
- Return type:
bool
Returns whether mouse input should exclusively remain with this item.
See also
- keepTouchGrab()¶
- Return type:
bool
Returns whether the touch points grabbed by this item should exclusively remain with this item.
See also
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.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()
.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.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()
.Maps the given
point
in the global screen coordinate system to the equivalent point within this item’s coordinate system, and returns the mapped coordinate.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
For example, this may be helpful to add a popup to a Qt Quick component.
Note
Window positioning is done by the window manager and this value is treated only as a hint. So, the resulting window position may differ from what is expected.
Note
If this item is in a subscene, e.g. mapped onto a 3D Model object, the UV mapping is incorporated into this transformation, so that it really goes from screen coordinates to this item’s coordinates, as long as
point
is actually within this item’s bounds. The other mapping functions do not yet work that way.See also
Concepts - Visual Coordinates in Qt Quick
- mapFromGlobal(x, y)
- Parameters:
x – float
y – float
- Return type:
- mapFromItem(item, point)¶
- Parameters:
item –
QQuickItem
point –
QPointF
- Return type:
Maps the given
point
initem
's coordinate system to the equivalent point within this item’s coordinate system, and returns the mapped coordinate.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
If
item
isNone
, this mapspoint
from the coordinate system of the scene.See also
Concepts - Visual Coordinates in Qt Quick
- mapFromItem(item, rect)
- Parameters:
item –
QQuickItem
rect –
QRectF
- Return type:
Maps the given
point
initem
's coordinate system to the equivalent point within this item’s coordinate system, and returns the mapped coordinate.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
If
item
isNone
, this mapspoint
from the coordinate system of the scene.See also
Concepts - Visual Coordinates in Qt Quick
- mapFromItem(item, x, y)
- Parameters:
item –
QQuickItem
x – float
y – float
- Return type:
- mapFromItem(item, x, y, width, height)
- Parameters:
item –
QQuickItem
x – float
y – float
width – float
height – float
- Return type:
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.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
See also
Concepts - Visual Coordinates in Qt Quick
- mapRectFromItem(item, rect)¶
- Parameters:
item –
QQuickItem
rect –
QRectF
- Return type:
Maps the given
rect
initem
's coordinate system to the equivalent rectangular area within this item’s coordinate system, and returns the mapped rectangle value.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
If
item
isNone
, this mapsrect
from the coordinate system of the scene.See also
Concepts - Visual Coordinates in Qt Quick
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.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
See also
Concepts - Visual Coordinates in Qt Quick
- mapRectToItem(item, rect)¶
- Parameters:
item –
QQuickItem
rect –
QRectF
- Return type:
Maps the given
rect
in this item’s coordinate system to the equivalent rectangular area withinitem
's coordinate system, and returns the mapped rectangle value.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
If
item
isNone
, this mapsrect
to the coordinate system of the scene.See also
Concepts - Visual Coordinates in Qt Quick
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.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
See also
Concepts - Visual Coordinates in Qt Quick
Maps the given
point
in this item’s coordinate system to the equivalent point within global screen coordinate system, and returns the mapped coordinate.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
For example, this may be helpful to add a popup to a Qt Quick component.
Note
Window positioning is done by the window manager and this value is treated only as a hint. So, the resulting window position may differ from what is expected.
See also
Concepts - Visual Coordinates in Qt Quick
- mapToGlobal(x, y)
- Parameters:
x – float
y – float
- Return type:
- mapToItem(item, point)¶
- Parameters:
item –
QQuickItem
point –
QPointF
- Return type:
Maps the given
point
in this item’s coordinate system to the equivalent point withinitem
's coordinate system, and returns the mapped coordinate.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
If
item
isNone
, this mapspoint
to the coordinate system of the scene.See also
Concepts - Visual Coordinates in Qt Quick
- mapToItem(item, rect)
- Parameters:
item –
QQuickItem
rect –
QRectF
- Return type:
Maps the given
point
in this item’s coordinate system to the equivalent point withinitem
's coordinate system, and returns the mapped coordinate.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
If
item
isNone
, this mapspoint
to the coordinate system of the scene.See also
Concepts - Visual Coordinates in Qt Quick
- mapToItem(item, x, y)
- Parameters:
item –
QQuickItem
x – float
y – float
- Return type:
- mapToItem(item, x, y, width, height)
- Parameters:
item –
QQuickItem
x – float
y – float
width – float
height – float
- Return type:
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.The following properties of the item are used in the mapping:
x
,y
,scale
,rotation
,transformOrigin
, and transform .If the items are part of different scenes, the mapping includes the relative position of the two scenes.
See also
Concepts - Visual Coordinates in Qt Quick
- mouseDoubleClickEvent(event)¶
- Parameters:
event –
QMouseEvent
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.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()
.- mouseMoveEvent(event)¶
- Parameters:
event –
QMouseEvent
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
mousePressEvent()
, for example) andacceptedMouseButtons()
must return the relevant mouse button.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()
.- mousePressEvent(event)¶
- Parameters:
event –
QMouseEvent
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,
acceptedMouseButtons()
must return the relevant mouse button.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()
.- mouseReleaseEvent(event)¶
- Parameters:
event –
QMouseEvent
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
mousePressEvent()
, for example) andacceptedMouseButtons()
must return the relevant mouse button.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()
.- mouseUngrabEvent()¶
This event handler can be reimplemented in a subclass to be notified when a mouse ungrab event has occurred on this item.
- nextItemInFocusChain([forward=true])¶
- Parameters:
forward – bool
- Return type:
Returns the item in the focus chain which is next to this item. If
forward
istrue
, or not supplied, it is the next item in the forwards direction. Ifforward
isfalse
, it is the next item in the backwards direction.- opacity()¶
- Return type:
float
See also
Getter of property
opacityᅟ
.- opacityChanged()¶
Notification signal of property
opacityᅟ
.- paletteChanged()¶
- paletteCreated()¶
- parentChanged(arg__1)¶
- Parameters:
arg__1 –
QQuickItem
Notification signal of property
parentᅟ
.- parentItem()¶
- Return type:
See also
Getter of property
parentᅟ
.- polish()¶
Schedules a polish event for this item.
When the scene graph processes the request, it will call
updatePolish()
on this item.See also
- releaseResources()¶
This function is called when an item should release graphics resources which are not already managed by the nodes returned from
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
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
scheduleRenderJob()
.See also
Graphics Resource Handling
- resetAntialiasing()¶
Reset function of property
antialiasingᅟ
.- resetHeight()¶
Reset function of property
heightᅟ
.- resetWidth()¶
Reset function of property
widthᅟ
.- rotation()¶
- Return type:
float
See also
Getter of property
rotationᅟ
.- rotationChanged()¶
Notification signal of property
rotationᅟ
.- scale()¶
- Return type:
float
See also
Getter of property
scaleᅟ
.- scaleChanged()¶
Notification signal of property
scaleᅟ
.- scopedFocusItem()¶
- Return type:
If this item is a focus scope, this returns the item in its focus chain that currently has focus.
Returns
None
if this item is not a focus scope.- setAcceptHoverEvents(enabled)¶
- Parameters:
enabled – bool
If
enabled
is true, this sets the item to accept hover events; otherwise, hover events are not accepted by this item.See also
- setAcceptTouchEvents(accept)¶
- Parameters:
accept – bool
If
enabled
is true, this sets the item to accept touch events; otherwise, touch events are not accepted by this item.See also
- setAcceptedMouseButtons(buttons)¶
- Parameters:
buttons – Combination of
MouseButton
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 callsetAcceptTouchEvents()
to continue to receive them.See also
- setActiveFocusOnTab(arg__1)¶
- Parameters:
arg__1 – bool
See also
Setter of property
activeFocusOnTabᅟ
.- setAntialiasing(arg__1)¶
- Parameters:
arg__1 – bool
See also
Setter of property
antialiasingᅟ
.- setBaselineOffset(arg__1)¶
- Parameters:
arg__1 – float
See also
Setter of property
baselineOffsetᅟ
.Setter of property
clipᅟ
.Setter of property
containmentMaskᅟ
.Sets the
cursor
shape for this item.See also
- setEnabled(arg__1)¶
- Parameters:
arg__1 – bool
See also
Setter of property
enabledᅟ
.- setFiltersChildMouseEvents(filter)¶
- Parameters:
filter – bool
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
Enables the specified
flag
for this item ifenabled
is true; ifenabled
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.Enables the specified
flags
for this item.- setFocus(arg__1)¶
- Parameters:
arg__1 – bool
See also
Setter of property
focusᅟ
.- setFocus(focus, reason)
- Parameters:
focus – bool
reason –
FocusReason
- setFocusPolicy(policy)¶
- Parameters:
policy –
FocusPolicy
Sets the focus policy of this item to
policy
.See also
Setter of property
focusPolicyᅟ
.Setter of property
heightᅟ
.- setImplicitHeight(arg__1)¶
- Parameters:
arg__1 – float
See also
Setter of property
implicitHeightᅟ
.- setImplicitSize(arg__1, arg__2)¶
- Parameters:
arg__1 – float
arg__2 – float
- setImplicitWidth(arg__1)¶
- Parameters:
arg__1 – float
See also
Setter of property
implicitWidthᅟ
.- setKeepMouseGrab(arg__1)¶
- Parameters:
arg__1 – bool
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. OncekeepMouseGrab
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, Flickable may attempt to steal a mouse grab if it detects that the user has begun to move the viewport.See also
- setKeepTouchGrab(arg__1)¶
- Parameters:
arg__1 – bool
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, Flickable may attempt to steal a touch point grab if it detects that the user has begun to move the viewport.See also
Setter of property
opacityᅟ
.- setParentItem(parent)¶
- Parameters:
parent –
QQuickItem
See also
Setter of property
parentᅟ
.- setRotation(arg__1)¶
- Parameters:
arg__1 – float
See also
Setter of property
rotationᅟ
.Setter of property
scaleᅟ
.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.Setter of property
smoothᅟ
.Setter of property
stateᅟ
.- setTransformOrigin(arg__1)¶
- Parameters:
arg__1 –
TransformOrigin
See also
Setter of property
transformOriginᅟ
.- setVisible(arg__1)¶
- Parameters:
arg__1 – bool
See also
Setter of property
visibleᅟ
.Setter of property
widthᅟ
.Setter of property
xᅟ
.Setter of property
yᅟ
.Setter of property
zᅟ
.Returns the size of the item.
- smooth()¶
- Return type:
bool
See also
Getter of property
smoothᅟ
.- smoothChanged(arg__1)¶
- Parameters:
arg__1 – bool
Notification signal of property
smoothᅟ
.- stackAfter(arg__1)¶
- Parameters:
arg__1 –
QQuickItem
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 totrue
, this will also cause the tab focus order to change, withsibling
receiving focus before this item.The given
sibling
must be a sibling of this item; that is, they must have the same immediateparent
.See also
Concepts - Visual Parent in Qt Quick
- stackBefore(arg__1)¶
- Parameters:
arg__1 –
QQuickItem
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 totrue
, this will also cause the tab focus order to change, withsibling
receiving focus after this item.The given
sibling
must be a sibling of this item; that is, they must have the same immediateparent
.See also
Concepts - Visual Parent in Qt Quick
- state()¶
- Return type:
str
See also
Getter of property
stateᅟ
.- stateChanged(arg__1)¶
- Parameters:
arg__1 – str
Notification signal of property
stateᅟ
.- textureProvider()¶
- Return type:
Returns the texture provider for an item. The default implementation returns
None
.This function may only be called on the rendering thread.
- touchEvent(event)¶
- Parameters:
event –
QTouchEvent
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.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()
.- touchUngrabEvent()¶
This event handler can be reimplemented in a subclass to be notified when a touch ungrab event has occurred on this item.
- transformOrigin()¶
- Return type:
See also
Getter of property
transformOriginᅟ
.- transformOriginChanged(arg__1)¶
- Parameters:
arg__1 –
TransformOrigin
Notification signal of property
transformOriginᅟ
.Getter of property
transformOriginPointᅟ
.- ungrabMouse()¶
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.
- ungrabTouchPoints()¶
Use QEventPoint::setExclusiveGrabber() instead. Ungrabs the touch points owned by this item.
- unsetCursor()¶
Clears the cursor shape for this item.
See also
- update()¶
Schedules a call to
updatePaintNode()
for this item.The call to
updatePaintNode()
will always happen if the item is showing in aQQuickWindow
.Only items which specify
ItemHasContents
are allowed to call QQuickItem::update().- updateInputMethod([queries=Qt.ImQueryInput])¶
- Parameters:
queries – Combination of
InputMethodQuery
Notify input method on updated query values if needed.
queries
indicates the changed attributes.- updatePaintNode(arg__1, arg__2)¶
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
update()
, if the user has set theItemHasContents
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 theQSGTransformNode
associated with thisQQuickItem
.QSGNode *MyItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *) { QSGSimpleRectNode *n = static_cast<QSGSimpleRectNode *>(node); if (!n) { n = new QSGSimpleRectNode(); n->setColor(Qt::red); } n->setRect(boundingRect()); return n; }
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
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.
Warning
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 Scene Graph and Rendering for more information.
See also
QSGMaterial
QSGGeometryNode
QSGGeometry
QSGFlatColorMaterial
QSGTextureMaterial
markDirty()
Graphics Resource Handling
- updatePolish()¶
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
- viewportItem()¶
- Return type:
If the
ItemObservesViewport
flag is set, returns the nearest parent with theItemIsViewport
flag. Returns the window’s contentItem if the flag is not set, or if no other viewport item is found.Returns
None
only if there is no viewport item and this item is not shown in a window.See also
- visibleChanged()¶
Notification signal of property
visibleᅟ
.- visibleChildrenChanged()¶
- wheelEvent(event)¶
- Parameters:
event –
QWheelEvent
This event handler can be reimplemented in a subclass to receive wheel events for an item. The event information is provided by the
event
parameter.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()
.- width()¶
- Return type:
float
See also
Getter of property
widthᅟ
.- widthChanged()¶
Notification signal of property
widthᅟ
.- widthValid()¶
- Return type:
bool
Returns whether the width property has been set explicitly.
- window()¶
- Return type:
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
windowChanged()
signal provides a notification both when the item is entered into a scene and when it is removed from a scene.- windowChanged(window)¶
- Parameters:
window –
QQuickWindow
This signal is emitted when the item’s
window
changes.Getter of property
xᅟ
.- xChanged()¶
Notification signal of property
xᅟ
.Getter of property
yᅟ
.- yChanged()¶
Notification signal of property
yᅟ
.Getter of property
zᅟ
.- zChanged()¶
Notification signal of property
zᅟ
.