QQuickItem ClassProvides the most basic of all visual items in QML More... #include <QQuickItem> Inherits: QObject and QQmlParserStatus. Inherited by: QQuickPaintedItem. QQuickItem is instantiated by QML element Item Public Types
Properties
Public Functions
Public Slots
Signals
Protected Functions
Reimplemented Protected Functions
Additional Inherited Members
Detailed DescriptionProvides the most basic of all visual items in QML All visual items in Qt Quick inherit from QQuickItem. Although QQuickItem has no visual appearance, it defines all the properties that are common across visual items - such as the x and y position, the width and height, anchoring and key handling. You can subclass QQuickItem to provide your own custom visual item that inherits these features. Custom Items using Scene GraphAll visual QML items are rendered using the scene graph, a low-level, high-performance rendering stack, closely tied to OpenGL. 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. Warning: It is crucial that OpenGL 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. To read more about how the scene graph rendering works, see Scene Graph and Rendering Custom Items using QPainterThe 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, either using software rasterization or using an OpenGL framebuffer object (FBO), 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. See also QQuickCanvas and QQuickPaintedItem. Member Type Documentation
flags QQuickItem::Flags |
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. |
This property holds speciifies 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:
qreal | baselineOffset() const |
void | setBaselineOffset(qreal) |
Notifier signal:
void | childrenChanged() |
This property specifies the geometry of an item's children.
This property holds the (collective) position and size of the item's children.
Access functions:
QRectF | childrenRect() |
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.
Non-rectangular clipping regions are not supported for performance reasons.
Access functions:
bool | clip() const |
void | setClip(bool) |
Access functions:
bool | isEnabled() const |
void | setEnabled(bool) |
Notifier signal:
void | enabledChanged() |
Access functions:
qreal | height() const |
void | setHeight(qreal) |
void | resetHeight() |
Notifier signal:
void | heightChanged() |
Access functions:
qreal | implicitHeight() const |
Notifier signal:
void | implicitHeightChanged() |
Access functions:
qreal | implicitWidth() const |
Notifier signal:
void | implicitWidthChanged() |
Access functions:
qreal | opacity() const |
void | setOpacity(qreal) |
Notifier signal:
void | opacityChanged() |
This property holds the parent of the item.
Access functions:
QQuickItem * | parentItem() const |
void | setParentItem(QQuickItem * parent) |
Access functions:
QPointF | pos() const |
Access functions:
qreal | rotation() const |
void | setRotation(qreal) |
Notifier signal:
void | rotationChanged() |
Access functions:
qreal | scale() const |
void | setScale(qreal) |
Notifier signal:
void | scaleChanged() |
This property specifies whether the item is smoothed or not.
Primarily used in image based elements 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 is true.
Access functions:
bool | smooth() const |
void | setSmooth(bool smooth) |
Access functions:
bool | isVisible() const |
void | setVisible(bool) |
Notifier signal:
void | visibleChanged() |
Notifier signal:
void | visibleChildrenChanged() |
Access functions:
qreal | width() const |
void | setWidth(qreal) |
void | resetWidth() |
Notifier signal:
void | widthChanged() |
Access functions:
qreal | x() const |
void | setX(qreal) |
Notifier signal:
void | xChanged() |
Access functions:
qreal | y() const |
void | setY(qreal) |
Notifier signal:
void | yChanged() |
Access functions:
qreal | z() const |
void | setZ(qreal) |
Notifier signal:
void | zChanged() |
Constructs a QQuickItem with the given parent.
Destroys the QQuickItem.
See also setAcceptHoverEvents().
See also setAcceptedMouseButtons().
Returns true if this item contains point, which is in local coordinates; returns false otherwise.
This function can be overwritten in order to handle point collisions in items with custom shapes. The default implementation checks if the point is inside the item's bounding rect.
Note that it's normally used to check if the item is under the mouse cursor, and for that reason, the implementation of this function should be as light-weight as possible.
See also setFiltersChildMouseEvents().
See also setFlags().
This function is called to handle this item's changes in geometry from oldGeometry to newGeometry. If the two geometries are the same, it doesn't do anything.
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.
See also ungrabTouchPoints() and setKeepTouchGrab().
Returns whether the height property has been set explicitly.
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().
Returns true if this item is a texture provider. The default implementation returns false.
This function can be called from any thread.
See also setKeepMouseGrab().
Returns a value indicating whether the touch points grabbed by this item should remain with this item exclusively.
See also setKeepTouchGrab() and keepMouseGrab().
This function is called when the item's scene graph resources are no longer needed. It allows items to free its resources, for instance textures, that are not owned by scene graph nodes. Note that scene graph nodes are managed by QQuickCanvas and should not be deleted by this function. Scene graph resources are no longer needed when the parent is set to null and the item is not used by any ShaderEffect or ShaderEffectSource.
This function is called from the main thread. Therefore, resources used by the scene graph should not be deleted directly, but by calling QObject::deleteLater().
Note: The item destructor still needs to free its scene graph resources if not already done.
See also acceptHoverEvents().
See also acceptedMouseButtons().
See also filtersChildMouseEvents().
See also flags().
See also hasFocus().
Sets the implied height of the item to h. This is the height implied by other properties that determine the content.
See also implicitHeight().
Sets the implied width of the item to w. This is the width implied by other properties that determine the content.
See also implicitWidth().
The flag indicating whether the mouse should remain with this item is set to keep.
This is useful for items that wish to grab and keep mouse interaction following a predefined gesture. For example, an item that is interested in horizontal mouse movement may set keepMouseGrab to true once a threshold has been exceeded. Once keepMouseGrab has been set to true, filtering items will not react to mouse events.
If the item does not indicate that it wishes to retain mouse grab, 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 keepMouseGrab().
The flag indicating whether the touch points grabbed by this item should remain with this item is set to keep.
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 the item does not indicate that it wishes to retain touch point grab, 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 keepTouchGrab() and setKeepMouseGrab().
See also pos().
See also state().
See also transformOrigin().
See also transformOriginPoint().
See also setState().
Returns the texture provider for an item. The default implementation returns 0.
This function may only be called on the rendering thread.
See also setTransformOrigin().
See also setTransformOriginPoint().
Ungrabs the touch points owned by this item.
See also grabTouchPoints().
Schedules a call to updatePaintNode() for this item.
The call to QQuickItem::updatePaintNode() will always happen if the item is showing in a QQuickCanvas.
Only items which specifies QQuickItem::ItemHasContents are allowed to call QQuickItem::update().
Notify input method on updated query values if needed. indicates changed attributes.
Called by the rendering thread, as a result of QQuickItem::update(), when it is time to sync the state of the QML objects with the scene graph objects.
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.
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 QSGNode::markDirty() or adding and removing nodes, then the underlying implementation may decide to not render the scene again as the visual outcome is identical.
Warning: It is crucial that OpenGL operations and interaction with the scene graph happens exclusively on the rendering 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.
See also QSGMaterial, QSGSimpleMaterial, QSGGeometryNode, QSGGeometry, QSGFlatColorMaterial, QSGTextureMaterial, and QSGNode::markDirty().
Returns whether the width property has been set explicitly.