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

The QQuickPaintedItem class provides a way to use the QPainter API in the QML Scene Graph. More...

#include <qquickpainteditem.h>

Inheritance diagram for QQuickPaintedItem:
Collaboration diagram for QQuickPaintedItem:

Public Types

enum  RenderTarget { Image , FramebufferObject , InvertedYFramebufferObject }
 This enum describes QQuickPaintedItem's render targets. More...
enum  PerformanceHint { FastFBOResizing = 0x1 }
 This enum describes flags that you can enable to improve rendering performance in QQuickPaintedItem. More...
Public Types inherited from QQuickItem
enum  Flag {
  ItemClipsChildrenToShape = 0x01 , ItemIsFocusScope = 0x04 , ItemHasContents = 0x08 , ItemAcceptsDrops = 0x10 ,
  ItemIsViewport = 0x20 , ItemObservesViewport = 0x40
}
 \qmltype Item \nativetype QQuickItem \inherits QtObject \inqmlmodule QtQuick More...
enum  ItemChange {
  ItemChildAddedChange , ItemChildRemovedChange , ItemSceneChange , ItemVisibleHasChanged ,
  ItemParentHasChanged , ItemOpacityHasChanged , ItemActiveFocusHasChanged , ItemRotationHasChanged ,
  ItemAntialiasingHasChanged , ItemDevicePixelRatioHasChanged , ItemEnabledHasChanged , ItemScaleHasChanged ,
  ItemTransformHasChanged
}
 Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes. More...
enum  TransformOrigin {
  TopLeft , Top , TopRight , Left ,
  Center , Right , BottomLeft , Bottom ,
  BottomRight
}
 \variable QQuickItem::ItemChangeData::realValue The numeric value that has changed: \l {QQuickItem::opacity()}{opacity}, \l {QQuickItem::rotation()}{rotation}, or \l {QQuickItem::scale()}{scale}, or \l {QScreen::devicePixelRatio}{device pixel ratio}. More...

Signals

void fillColorChanged ()
void contentsSizeChanged ()
void contentsScaleChanged ()
void renderTargetChanged ()
void textureSizeChanged ()
Signals inherited from QQuickItem
void childrenRectChanged (const QRectF &)
void baselineOffsetChanged (qreal)
void stateChanged (const QString &)
void focusChanged (bool)
void activeFocusChanged (bool)
Q_REVISION(6, 7) void focusPolicyChanged(Qt Q_REVISION (2, 1) void activeFocusOnTabChanged(bool)
void parentChanged (QQuickItem *)
void transformOriginChanged (TransformOrigin)
void smoothChanged (bool)
void antialiasingChanged (bool)
void clipChanged (bool)
 Q_REVISION (2, 1) void windowChanged(QQuickWindow *window)
void childrenChanged ()
void opacityChanged ()
void enabledChanged ()
void visibleChanged ()
void visibleChildrenChanged ()
void rotationChanged ()
void scaleChanged ()
void xChanged ()
void yChanged ()
void widthChanged ()
void heightChanged ()
void zChanged ()
void implicitWidthChanged ()
void implicitHeightChanged ()
 Q_REVISION (2, 11) void containmentMaskChanged()
 Q_REVISION (6, 0) void paletteChanged()
 Q_REVISION (6, 0) void paletteCreated()
Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.

Public Member Functions

 QQuickPaintedItem (QQuickItem *parent=nullptr)
 Constructs a QQuickPaintedItem with the given parent item.
 ~QQuickPaintedItem () override
 Destroys the QQuickPaintedItem.
void update (const QRect &rect=QRect())
 Schedules a redraw of the area covered by rect in this item.
bool opaquePainting () const
 Returns true if this item is opaque; otherwise, false is returned.
void setOpaquePainting (bool opaque)
 If opaque is true, the item is opaque; otherwise, it is considered as translucent.
bool antialiasing () const
 Returns true if antialiased painting is enabled; otherwise, false is returned.
void setAntialiasing (bool enable)
 If enable is true, antialiased painting is enabled.
bool mipmap () const
 Returns true if mipmaps are enabled; otherwise, false is returned.
void setMipmap (bool enable)
 If enable is true, mipmapping is enabled on the associated texture.
PerformanceHints performanceHints () const
 Returns the performance hints.
void setPerformanceHint (PerformanceHint hint, bool enabled=true)
 Sets the given performance hint on the item if enabled is true; otherwise clears the performance hint.
void setPerformanceHints (PerformanceHints hints)
 Sets the performance hints to hints.
QRectF contentsBoundingRect () const
QSize contentsSize () const
void setContentsSize (const QSize &)
void resetContentsSize ()
qreal contentsScale () const
void setContentsScale (qreal)
QSize textureSize () const
void setTextureSize (const QSize &size)
QColor fillColor () const
void setFillColor (const QColor &)
RenderTarget renderTarget () const
void setRenderTarget (RenderTarget target)
virtual void paint (QPainter *painter)=0
 This function, which is usually called by the QML Scene Graph, paints the contents of an item in local coordinates.
bool isTextureProvider () const override
 \reimp
QSGTextureProvidertextureProvider () const override
 \reimp
Public Member Functions inherited from QQuickItem
 QQuickItem (QQuickItem *parent=nullptr)
 Constructs a QQuickItem with the given parent.
 ~QQuickItem () override
 Destroys the QQuickItem.
QQuickWindowwindow () const
 Returns the window in which this item is rendered.
QQuickItemparentItem () const
void setParentItem (QQuickItem *parent)
void stackBefore (const QQuickItem *)
 Moves this item to the index before the specified sibling item within the list of children.
void stackAfter (const QQuickItem *)
 Moves this item to the index after the specified sibling item within the list of children.
QRectF childrenRect ()
 \qmlpropertygroup QtQuick::Item::childrenRect \qmlproperty real QtQuick::Item::childrenRect.x \qmlproperty real QtQuick::Item::childrenRect.y \qmlproperty real QtQuick::Item::childrenRect.width \qmlproperty real QtQuick::Item::childrenRect.height \readonly
QList< QQuickItem * > childItems () const
 Returns the children of this item.
bool clip () const
 \qmlproperty bool QtQuick::Item::clip This property holds whether clipping is enabled.
void setClip (bool)
QString state () const
 \qmlproperty string QtQuick::Item::state
void setState (const QString &)
qreal baselineOffset () const
 \qmlproperty int QtQuick::Item::baselineOffset
void setBaselineOffset (qreal)
QQmlListProperty< QQuickTransformtransform ()
qreal x () const
qreal y () const
QPointF position () const
void setX (qreal)
void setY (qreal)
void setPosition (const QPointF &)
QBindable< qrealbindableX ()
QBindable< qrealbindableY ()
qreal width () const
void setWidth (qreal)
void resetWidth ()
void setImplicitWidth (qreal)
qreal implicitWidth () const
 Returns the width of the item that is implied by other properties that determine the content.
QBindable< qrealbindableWidth ()
qreal height () const
void setHeight (qreal)
void resetHeight ()
void setImplicitHeight (qreal)
qreal implicitHeight () const
QBindable< qrealbindableHeight ()
QSizeF size () const
void setSize (const QSizeF &size)
TransformOrigin transformOrigin () const
void setTransformOrigin (TransformOrigin)
QPointF transformOriginPoint () const
void setTransformOriginPoint (const QPointF &)
qreal z () const
void setZ (qreal)
qreal rotation () const
void setRotation (qreal)
qreal scale () const
void setScale (qreal)
qreal opacity () const
void setOpacity (qreal)
bool isVisible () const
void setVisible (bool)
bool isEnabled () const
void setEnabled (bool)
bool smooth () const
void setSmooth (bool)
bool activeFocusOnTab () const
 \qmlproperty bool QtQuick::Item::activeFocusOnTab
void setActiveFocusOnTab (bool)
bool antialiasing () const
void setAntialiasing (bool)
void resetAntialiasing ()
Flags flags () const
 Returns the item flags for this item.
void setFlag (Flag flag, bool enabled=true)
 Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disabled.
void setFlags (Flags flags)
 Enables the specified flags for this item.
virtual QRectF boundingRect () const
 Returns the extents of the item in its own coordinate system: a rectangle from {0, 0} to \l width() and \l height().
virtual QRectF clipRect () const
 Returns the rectangular area within this item that is currently visible in \l viewportItem(), if there is a viewport and the \l ItemObservesViewport flag is set; otherwise, the extents of this item in its own coordinate system: a rectangle from {0, 0} to \l width() and \l height().
QQuickItemviewportItem () const
 If the \l ItemObservesViewport flag is set, returns the nearest parent with the \l ItemIsViewport flag.
bool hasActiveFocus () const
bool hasFocus () const
void setFocus (bool)
void setFocus (bool focus, Qt::FocusReason reason)
bool isFocusScope () const
 Returns true if this item is a focus scope, and false otherwise.
QQuickItemscopedFocusItem () const
 If this item is a focus scope, this returns the item in its focus chain that currently has focus.
Qt::FocusPolicy focusPolicy () const
void setFocusPolicy (Qt::FocusPolicy policy)
 Sets the focus policy of this item to policy.
bool isAncestorOf (const QQuickItem *child) const
 Returns true if this item is an ancestor of child (i.e., if this item is child's parent, or one of child's parent's ancestors).
Qt::MouseButtons acceptedMouseButtons () const
 Returns the mouse buttons accepted by this item.
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 Sets the mouse buttons accepted by this item to buttons.
bool acceptHoverEvents () const
 Returns whether hover events are accepted by this item.
void setAcceptHoverEvents (bool enabled)
 If enabled is true, this sets the item to accept hover events; otherwise, hover events are not accepted by this item.
bool acceptTouchEvents () const
 Returns whether touch events are accepted by this item.
void setAcceptTouchEvents (bool accept)
 If enabled is true, this sets the item to accept touch events; otherwise, touch events are not accepted by this item.
bool isUnderMouse () const
void grabMouse ()
void ungrabMouse ()
bool keepMouseGrab () const
 Returns whether mouse input should exclusively remain with this item.
void setKeepMouseGrab (bool)
 Sets whether the mouse input should remain exclusively with this item.
bool filtersChildMouseEvents () const
 Returns whether pointer events intended for this item's children should be filtered through this item.
void setFiltersChildMouseEvents (bool filter)
 Sets whether pointer events intended for this item's children should be filtered through this item.
void grabTouchPoints (const QList< int > &ids)
void ungrabTouchPoints ()
bool keepTouchGrab () const
 Returns whether the touch points grabbed by this item should exclusively remain with this item.
void setKeepTouchGrab (bool)
 Sets whether the touch points grabbed by this item should remain exclusively with this item.
 Q_REVISION (2, 4) Q_INVOKABLE bool grabToImage(const QJSValue &callback
QSharedPointer< QQuickItemGrabResultgrabToImage (const QSize &targetSize=QSize())
 Grabs the item into an in-memory image.
virtual Q_INVOKABLE bool contains (const QPointF &point) const
 \qmlmethod bool QtQuick::Item::contains(point point)
QObjectcontainmentMask () const
void setContainmentMask (QObject *mask)
QTransform itemTransform (QQuickItem *, bool *) const
 \qmlmethod point QtQuick::Item::mapFromItem(Item item, real x, real y) \qmlmethod point QtQuick::Item::mapFromItem(Item item, point p) \qmlmethod rect QtQuick::Item::mapFromItem(Item item, real x, real y, real width, real height) \qmlmethod rect QtQuick::Item::mapFromItem(Item item, rect r)
QPointF mapToScene (const QPointF &point) const
 Maps the given point in this item's coordinate system to the equivalent point within the scene's coordinate system, and returns the mapped coordinate.
QRectF mapRectToItem (const QQuickItem *item, const QRectF &rect) const
 Maps the given rect in this item's coordinate system to the equivalent rectangular area within item's coordinate system, and returns the mapped rectangle value.
QRectF mapRectToScene (const QRectF &rect) const
 Maps the given rect in this item's coordinate system to the equivalent rectangular area within the scene's coordinate system, and returns the mapped rectangle value.
QPointF mapFromScene (const QPointF &point) const
 Maps the given point in the scene's coordinate system to the equivalent point within this item's coordinate system, and returns the mapped coordinate.
QRectF mapRectFromItem (const QQuickItem *item, const QRectF &rect) const
 Maps the given rect in item's coordinate system to the equivalent rectangular area within this item's coordinate system, and returns the mapped rectangle value.
QRectF mapRectFromScene (const QRectF &rect) const
 Maps the given rect in the scene's coordinate system to the equivalent rectangular area within this item's coordinate system, and returns the mapped rectangle value.
void polish ()
 Schedules a polish event for this item.
Q_INVOKABLE QPointF mapFromItem (const QQuickItem *item, const QPointF &point) const
 Maps the given point in item's coordinate system to the equivalent point within this item's coordinate system, and returns the mapped coordinate.
Q_INVOKABLE QPointF mapFromItem (const QQuickItem *item, qreal x, qreal y)
Q_INVOKABLE QRectF mapFromItem (const QQuickItem *item, const QRectF &rect) const
Q_INVOKABLE QRectF mapFromItem (const QQuickItem *item, qreal x, qreal y, qreal width, qreal height) const
Q_INVOKABLE QPointF mapToItem (const QQuickItem *item, const QPointF &point) const
 Maps the given point in this item's coordinate system to the equivalent point within item's coordinate system, and returns the mapped coordinate.
Q_INVOKABLE QPointF mapToItem (const QQuickItem *item, qreal x, qreal y)
Q_INVOKABLE QRectF mapToItem (const QQuickItem *item, const QRectF &rect) const
Q_INVOKABLE QRectF mapToItem (const QQuickItem *item, qreal x, qreal y, qreal width, qreal height) const
 Q_REVISION (2, 7) Q_INVOKABLE QPointF mapFromGlobal(qreal x
 Q_REVISION (2, 7) Q_INVOKABLE QPointF mapFromGlobal(const QPointF &point) const
 Q_REVISION (2, 7) Q_INVOKABLE QPointF mapToGlobal(qreal x
 Q_REVISION (2, 7) Q_INVOKABLE QPointF mapToGlobal(const QPointF &point) const
Q_INVOKABLE void forceActiveFocus ()
 \qmlmethod point QtQuick::Item::mapToItem(Item item, real x, real y) \qmlmethod point QtQuick::Item::mapToItem(Item item, point p) \qmlmethod rect QtQuick::Item::mapToItem(Item item, real x, real y, real width, real height) \qmlmethod rect QtQuick::Item::mapToItem(Item item, rect r)
Q_INVOKABLE void forceActiveFocus (Qt::FocusReason reason)
 \qmlmethod QtQuick::Item::forceActiveFocus(Qt::FocusReason reason) This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Forces active focus on the item with the given reason.
 Q_REVISION (2, 1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward
Q_INVOKABLE QQuickItemchildAt (qreal x, qreal y) const
 \qmlmethod Item QtQuick::Item::childAt(real x, real y)
 Q_REVISION (6, 3) Q_INVOKABLE void ensurePolished()
 Q_REVISION (6, 3) Q_INVOKABLE void dumpItemTree() const
Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
QString objectName () const
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
QBindable< QStringbindableObjectName ()
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
bool isQmlObjectType () const
 Returns whether the object has been created by the QML engine or ownership has been explicitly set via QJSEngine::setObjectOwnership().
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
QThreadthread () const
 Returns the thread in which the object lives.
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
void killTimer (int id)
 Kills the timer with timer identifier, id.
void killTimer (Qt::TimerId id)
template<typename T>
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
template<typename T>
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
template<typename T>
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename T>
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const QObjectListchildren () const
 Returns a list of child objects.
void setParent (QObject *parent)
 Makes the object a child of parent.
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
bool disconnect (const QObject *receiver, const char *member=nullptr) const
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
bool setProperty (const char *name, QVariant &&value)
QVariant property (const char *name) const
 Returns the value of the object's name property.
QList< QByteArraydynamicPropertyNames () const
QBindingStoragebindingStorage ()
const QBindingStoragebindingStorage () const
QObjectparent () const
 Returns a pointer to the parent object.
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
Public Member Functions inherited from QQmlParserStatus
 QQmlParserStatus ()
virtual ~QQmlParserStatus ()

Protected Member Functions

 QQuickPaintedItem (QQuickPaintedItemPrivate &dd, QQuickItem *parent=nullptr)
QSGNodeupdatePaintNode (QSGNode *, UpdatePaintNodeData *) override
 \reimp
void releaseResources () override
 \reimp
void itemChange (ItemChange, const ItemChangeData &) override
 \reimp
Protected Member Functions inherited from QQuickItem
bool event (QEvent *) override
 \reimp
bool isComponentComplete () const
 Returns true if construction of the QML component is complete; otherwise returns false.
virtual void geometryChange (const QRectF &newGeometry, const QRectF &oldGeometry)
bool widthValid () const
 Returns whether the width property has been set explicitly.
bool heightValid () const
 Returns whether the height property has been set explicitly.
void setImplicitSize (qreal, qreal)
void classBegin () override
 \reimp Derived classes should call the base class method before adding their own action to perform at classBegin.
void componentComplete () override
 \reimp Derived classes should call the base class method before adding their own actions to perform at componentComplete.
virtual void keyPressEvent (QKeyEvent *event)
 This event handler can be reimplemented in a subclass to receive key press events for an item.
virtual void keyReleaseEvent (QKeyEvent *event)
 This event handler can be reimplemented in a subclass to receive key release events for an item.
virtual void focusInEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive focus-in events for an item.
virtual void focusOutEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive focus-out events for an item.
virtual void mousePressEvent (QMouseEvent *event)
 This event handler can be reimplemented in a subclass to receive mouse press events for an item.
virtual void mouseMoveEvent (QMouseEvent *event)
 This event handler can be reimplemented in a subclass to receive mouse move events for an item.
virtual void mouseReleaseEvent (QMouseEvent *event)
 This event handler can be reimplemented in a subclass to receive mouse release events for an item.
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 This event handler can be reimplemented in a subclass to receive mouse double-click events for an item.
virtual void mouseUngrabEvent ()
 This event handler can be reimplemented in a subclass to be notified when a mouse ungrab event has occurred on this item.
virtual void touchUngrabEvent ()
 This event handler can be reimplemented in a subclass to be notified when a touch ungrab event has occurred on this item.
virtual void touchEvent (QTouchEvent *event)
 This event handler can be reimplemented in a subclass to receive touch events for an item.
virtual void hoverEnterEvent (QHoverEvent *event)
 This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
virtual void hoverMoveEvent (QHoverEvent *event)
 This event handler can be reimplemented in a subclass to receive hover-move events for an item.
virtual void hoverLeaveEvent (QHoverEvent *event)
 This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
virtual bool childMouseEventFilter (QQuickItem *, QEvent *)
 Reimplement this method to filter the pointer events that are received by this item's children.
virtual bool contextMenuEvent (QContextMenuEvent *event)
virtual void updatePolish ()
 This function should perform any layout as required for this item.
 QQuickItem (QQuickItemPrivate &dd, QQuickItem *parent=nullptr)
Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
int senderSignalIndex () const
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
bool isSignalConnected (const QMetaMethod &signal) const
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
virtual void connectNotify (const QMetaMethod &signal)
virtual void disconnectNotify (const QMetaMethod &signal)
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)

Properties

QSize contentsSize
 Obsolete method for setting the contents size.
QColor fillColor
 The item's background fill color.
qreal contentsScale
 Obsolete method for scaling the contents.
RenderTarget renderTarget
 The item's render target.
QSize textureSize
 Defines the size of the texture.
Properties inherited from QQuickItem
QQuickItemparent
 \qmlproperty Item QtQuick::Item::parent This property holds the visual parent of the item.
qreal x
 \qmlproperty real QtQuick::Item::x \qmlproperty real QtQuick::Item::y \qmlproperty real QtQuick::Item::width \qmlproperty real QtQuick::Item::height
qreal y
 Defines the item's y position relative to its parent.
qreal z
 \qmlproperty real QtQuick::Item::z
qreal width
 This property holds the width of this item.
qreal height
 This property holds the height of this item.
qreal opacity
 \qmlproperty real QtQuick::Item::opacity
bool enabled
 \qmlproperty bool QtQuick::Item::enabled
bool visible
 \qmlproperty bool QtQuick::Item::visible
Qt::FocusPolicy focusPolicy
 \qmlproperty enumeration QtQuick::Item::focusPolicy
qreal rotation
 \qmlproperty real QtQuick::Item::rotation This property holds the rotation of the item in degrees clockwise around its transformOrigin.
qreal scale
 \qmlproperty real QtQuick::Item::scale This property holds the scale factor for this item.
TransformOrigin transformOrigin
 \qmlproperty enumeration QtQuick::Item::transformOrigin This property holds the origin point around which scale and rotation transform.
QPointF transformOriginPoint
QQmlListProperty< QQuickTransformtransform
 \qmlproperty list<Transform> QtQuick::Item::transform
bool smooth
 \qmlproperty bool QtQuick::Item::smooth
bool antialiasing
 \qmlproperty bool QtQuick::Item::antialiasing
qreal implicitWidth
qreal implicitHeight
QObjectcontainmentMask
 \qmlproperty QObject* QtQuick::Item::containmentMask
Properties inherited from QObject
QString objectName
 the name of this object

Additional Inherited Members

Public Slots inherited from QQuickItem
void update ()
 Schedules a call to updatePaintNode() for this item.
Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
template<typename Func1, typename Func2>
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
template<typename Func1, typename Func2>
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
template<typename Func1, typename Func2>
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
template<typename Func1>
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
Public Attributes inherited from QQuickItem
const QSizetargetSize = QSize())
qreal y const
Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr

Detailed Description

The QQuickPaintedItem class provides a way to use the QPainter API in the QML Scene Graph.

\inmodule QtQuick

The QQuickPaintedItem makes it possible to use the QPainter API with the QML Scene Graph. It sets up a textured rectangle in the Scene Graph and uses a QPainter to paint onto the texture. The render target in Qt 6 is always a QImage. When the render target is a QImage, QPainter first renders into the image then the content is uploaded to the texture. Call update() to trigger a repaint.

To enable QPainter to do anti-aliased rendering, use setAntialiasing().

To write your own painted item, you first create a subclass of QQuickPaintedItem, and then start by implementing its only pure virtual public function: paint(), which implements the actual painting. The painting will be inside the rectangle spanning from 0,0 to width(),height().

Note
It important to understand the performance implications such items can incur. See QQuickPaintedItem::RenderTarget and QQuickPaintedItem::renderTarget.
See also
{Scene Graph - Painted Item}, {Writing QML Extensions with C++}

Definition at line 16 of file qquickpainteditem.h.

Member Enumeration Documentation

◆ PerformanceHint

This enum describes flags that you can enable to improve rendering performance in QQuickPaintedItem.

By default, none of these flags are set.

\value FastFBOResizing As of Qt 6.0, this value is ignored.

Enumerator
FastFBOResizing 

Definition at line 41 of file qquickpainteditem.h.

◆ RenderTarget

This enum describes QQuickPaintedItem's render targets.

The render target is the surface QPainter paints onto before the item is rendered on screen.

\value Image The default; QPainter paints into a QImage using the raster paint engine. The image's content needs to be uploaded to graphics memory afterward, this operation can potentially be slow if the item is large. This render target allows high quality anti-aliasing and fast item resizing.

\value FramebufferObject As of Qt 6.9, this value will enable hardware-accelerated painting as long as the rendering API used is OpenGL, otherwise it will be ignored. For versions Qt 6.0 to Qt 6.8, it will be ignored on all rendering APIs. This will usually give better rendering performance, but at the expense of antialiasing quality.

\value InvertedYFramebufferObject Same as FramebufferObject, but with the rendering flipped around the X axis.

See also
setRenderTarget()
Enumerator
Image 
FramebufferObject 
InvertedYFramebufferObject 

Definition at line 34 of file qquickpainteditem.h.

Constructor & Destructor Documentation

◆ QQuickPaintedItem() [1/2]

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

Constructs a QQuickPaintedItem with the given parent item.

Definition at line 105 of file qquickpainteditem.cpp.

◆ ~QQuickPaintedItem()

QQuickPaintedItem::~QQuickPaintedItem ( )
override

Destroys the QQuickPaintedItem.

Definition at line 123 of file qquickpainteditem.cpp.

◆ QQuickPaintedItem() [2/2]

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

Definition at line 114 of file qquickpainteditem.cpp.

Member Function Documentation

◆ antialiasing()

bool QQuickPaintedItem::antialiasing ( ) const

Returns true if antialiased painting is enabled; otherwise, false is returned.

By default, antialiasing is not enabled.

See also
setAntialiasing()

Definition at line 193 of file qquickpainteditem.cpp.

◆ contentsBoundingRect()

QRectF QQuickPaintedItem::contentsBoundingRect ( ) const
Deprecated

This function is provided for compatibility, use size in combination with textureSize to decide the size of what you are drawing.

See also
width(), height(), textureSize()
Deprecated

This function is provided for compatibility, use size in combination with textureSize to decide the size of what you are drawing.

See also
width(), height(), textureSize()

Definition at line 331 of file qquickpainteditem.cpp.

◆ contentsScale()

qreal QQuickPaintedItem::contentsScale ( ) const

Definition at line 394 of file qquickpainteditem.cpp.

◆ contentsScaleChanged

void QQuickPaintedItem::contentsScaleChanged ( )
signal

◆ contentsSize()

QSize QQuickPaintedItem::contentsSize ( ) const

Definition at line 356 of file qquickpainteditem.cpp.

◆ contentsSizeChanged

void QQuickPaintedItem::contentsSizeChanged ( )
signal

◆ fillColor()

QColor QQuickPaintedItem::fillColor ( ) const

Definition at line 423 of file qquickpainteditem.cpp.

◆ fillColorChanged

void QQuickPaintedItem::fillColorChanged ( )
signal

◆ isTextureProvider()

bool QQuickPaintedItem::isTextureProvider ( ) const
overridevirtual

\reimp

Reimplemented from QQuickItem.

Definition at line 594 of file qquickpainteditem.cpp.

◆ itemChange()

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

\reimp

Reimplemented from QQuickItem.

Definition at line 627 of file qquickpainteditem.cpp.

◆ mipmap()

bool QQuickPaintedItem::mipmap ( ) const

Returns true if mipmaps are enabled; otherwise, false is returned.

By default, mipmapping is not enabled.

See also
setMipmap()

Definition at line 217 of file qquickpainteditem.cpp.

◆ opaquePainting()

bool QQuickPaintedItem::opaquePainting ( ) const

Returns true if this item is opaque; otherwise, false is returned.

By default, painted items are not opaque.

See also
setOpaquePainting()

Definition at line 158 of file qquickpainteditem.cpp.

◆ paint()

virtual void QQuickPaintedItem::paint ( QPainter * painter)
pure virtual

This function, which is usually called by the QML Scene Graph, paints the contents of an item in local coordinates.

The underlying texture will have a size defined by textureSize when set, or the item's size, multiplied by the window's device pixel ratio.

The function is called after the item has been filled with the fillColor.

Reimplement this function in a QQuickPaintedItem subclass to provide the item's painting implementation, using painter.

Note
The QML Scene Graph uses two separate threads, the main thread does things such as processing events or updating animations while a second thread does the actual issuing of graphics resource updates and the recording of draw calls. As a consequence, paint() is not called from the main GUI thread but from the GL enabled renderer thread. At the moment paint() is called, the GUI thread is blocked and this is therefore thread-safe.
Warning
Extreme caution must be used when creating QObjects, emitting signals, starting timers and similar inside this function as these will have affinity to the rendering thread.
See also
width(), height(), textureSize

Implemented in QDeclarativeGeoMapCopyrightNotice, QmlJSDebugger::HoverHighlight, QmlJSDebugger::SelectionHighlight, QQuickBasicDial, QQuickFluentWinUI3FocusStroke, QQuickFusionBusyIndicator, QQuickFusionDial, QQuickFusionKnob, QQuickMaterialTextContainer, and QQuickUniversalFocusRectangle.

◆ performanceHints()

QQuickPaintedItem::PerformanceHints QQuickPaintedItem::performanceHints ( ) const

Returns the performance hints.

By default, no performance hint is enabled.

See also
setPerformanceHint(), setPerformanceHints()

Definition at line 251 of file qquickpainteditem.cpp.

◆ releaseResources()

void QQuickPaintedItem::releaseResources ( )
overrideprotectedvirtual

\reimp

Reimplemented from QQuickItem.

Definition at line 573 of file qquickpainteditem.cpp.

◆ renderTarget()

QQuickPaintedItem::RenderTarget QQuickPaintedItem::renderTarget ( ) const

Definition at line 458 of file qquickpainteditem.cpp.

◆ renderTargetChanged

void QQuickPaintedItem::renderTargetChanged ( )
signal

◆ resetContentsSize()

void QQuickPaintedItem::resetContentsSize ( )
Deprecated
This convenience function is equivalent to calling setContentsSize(QSize()).
Deprecated
This convenience function is equivalent to calling setContentsSize(QSize()).

Definition at line 379 of file qquickpainteditem.cpp.

◆ setAntialiasing()

void QQuickPaintedItem::setAntialiasing ( bool enable)

If enable is true, antialiased painting is enabled.

By default, antialiasing is not enabled.

See also
antialiasing()

Definition at line 205 of file qquickpainteditem.cpp.

◆ setContentsScale()

void QQuickPaintedItem::setContentsScale ( qreal scale)

Definition at line 400 of file qquickpainteditem.cpp.

◆ setContentsSize()

void QQuickPaintedItem::setContentsSize ( const QSize & size)

Definition at line 362 of file qquickpainteditem.cpp.

◆ setFillColor()

void QQuickPaintedItem::setFillColor ( const QColor & c)

Definition at line 429 of file qquickpainteditem.cpp.

◆ setMipmap()

void QQuickPaintedItem::setMipmap ( bool enable)

If enable is true, mipmapping is enabled on the associated texture.

Mipmapping increases rendering speed and reduces aliasing artifacts when the item is scaled down.

By default, mipmapping is not enabled.

See also
mipmap()

Definition at line 233 of file qquickpainteditem.cpp.

◆ setOpaquePainting()

void QQuickPaintedItem::setOpaquePainting ( bool opaque)

If opaque is true, the item is opaque; otherwise, it is considered as translucent.

Opaque items are not blended with the rest of the scene, you should set this to true if the content of the item is opaque to speed up rendering.

By default, painted items are not opaque.

See also
opaquePainting()

Definition at line 174 of file qquickpainteditem.cpp.

◆ setPerformanceHint()

void QQuickPaintedItem::setPerformanceHint ( QQuickPaintedItem::PerformanceHint hint,
bool enabled = true )

Sets the given performance hint on the item if enabled is true; otherwise clears the performance hint.

By default, no performance hint is enabled/

See also
setPerformanceHints(), performanceHints()

Definition at line 265 of file qquickpainteditem.cpp.

◆ setPerformanceHints()

void QQuickPaintedItem::setPerformanceHints ( PerformanceHints hints)

Sets the performance hints to hints.

By default, no performance hint is enabled/

See also
setPerformanceHint(), performanceHints()

Definition at line 284 of file qquickpainteditem.cpp.

◆ setRenderTarget()

void QQuickPaintedItem::setRenderTarget ( RenderTarget target)

Definition at line 464 of file qquickpainteditem.cpp.

◆ setTextureSize()

void QQuickPaintedItem::setTextureSize ( const QSize & size)

Definition at line 314 of file qquickpainteditem.cpp.

◆ textureProvider()

QSGTextureProvider * QQuickPaintedItem::textureProvider ( ) const
overridevirtual

\reimp

Reimplemented from QQuickItem.

Definition at line 602 of file qquickpainteditem.cpp.

◆ textureSize()

QSize QQuickPaintedItem::textureSize ( ) const

Definition at line 293 of file qquickpainteditem.cpp.

◆ textureSizeChanged

void QQuickPaintedItem::textureSizeChanged ( )
signal

◆ update()

void QQuickPaintedItem::update ( const QRect & rect = QRect())

Schedules a redraw of the area covered by rect in this item.

You can call this function whenever your item needs to be redrawn, such as if it changes appearance or size.

This function does not cause an immediate paint; instead it schedules a paint request that is processed by the QML Scene Graph when the next frame is rendered. The item will only be redrawn if it is visible.

See also
paint()

Definition at line 140 of file qquickpainteditem.cpp.

◆ updatePaintNode()

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

\reimp

Reimplemented from QQuickItem.

Definition at line 508 of file qquickpainteditem.cpp.

Property Documentation

◆ contentsScale

qreal QQuickPaintedItem::contentsScale
readwrite

Obsolete method for scaling the contents.

Deprecated

This function is provided for compatibility, use size() in combination with textureSize() to decide the size of what you are drawing.

See also
width(), height(), textureSize()
Deprecated

This function is provided for compatibility, use size() in combination with textureSize() to decide the size of what you are drawing.

See also
width(), height(), textureSize()

Definition at line 22 of file qquickpainteditem.h.

◆ contentsSize

QSize QQuickPaintedItem::contentsSize
readwrite

Obsolete method for setting the contents size.

Deprecated

This function is provided for compatibility, use size in combination with textureSize to decide the size of what you are drawing.

See also
width(), height(), textureSize()
Deprecated

This function is provided for compatibility, use size in combination with textureSize to decide the size of what you are drawing.

See also
width(), height(), textureSize()

Definition at line 20 of file qquickpainteditem.h.

◆ fillColor

QColor QQuickPaintedItem::fillColor
readwrite

The item's background fill color.

By default, the fill color is set to Qt::transparent.

Set the fill color to an invalid color (e.g. QColor()) to disable background filling. This may improve performance, and is safe to do if the paint() function draws to all pixels on each frame.

Definition at line 21 of file qquickpainteditem.h.

◆ renderTarget

RenderTarget QQuickPaintedItem::renderTarget
readwrite

The item's render target.

This property defines which render target the QPainter renders into, it can be either QQuickPaintedItem::Image, QQuickPaintedItem::FramebufferObject or QQuickPaintedItem::InvertedYFramebufferObject.

Each has certain benefits, typically performance versus quality. Using a framebuffer object avoids a costly upload of the image contents to the texture in graphics memory, while using an image enables high quality anti-aliasing.

Warning
Resizing a framebuffer object is a costly operation, avoid using the QQuickPaintedItem::FramebufferObject render target if the item gets resized often.

By default, the render target is QQuickPaintedItem::Image.

Definition at line 23 of file qquickpainteditem.h.

◆ textureSize

QSize QQuickPaintedItem::textureSize
readwrite

Defines the size of the texture.

Changing the texture's size does not affect the coordinate system used in paint(). A scale factor is instead applied so painting should still happen inside 0,0 to width(),height().

By default, the texture size will have the same size as this item.

Note
If the item is on a window with a device pixel ratio different from 1, this scale factor will be implicitly applied to the texture size.

Definition at line 24 of file qquickpainteditem.h.


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