QQuickCPainterItem Class
The QQuickCPainterItem creates QtQuick item using QCPainter. More...
| Header: | #include <QQuickCPainterItem> |
| Inherits: | QQuickRhiItem |
Properties
|
|
Public Functions
| QQuickCPainterItem(QQuickItem *parent = nullptr) | |
| virtual | ~QQuickCPainterItem() override |
| Qt::MouseButtons | acceptedButtons() const |
| QString | backendName() const |
| QVariantMap | debug() |
| QColor | fillColor() const |
| bool | mouseEventsEnabled() const |
| bool | mouseHoverEventsEnabled() const |
| void | setAcceptedButtons(Qt::MouseButtons buttons) |
| void | setFillColor(const QColor &color) |
| void | setMouseEventsEnabled(bool enabled) |
| void | setMouseHoverEventsEnabled(bool enabled) |
Signals
| void | acceptedButtonsChanged() |
| void | backendNameChanged() |
| void | debugChanged() |
| void | fillColorChanged() |
| void | mouseEventsEnabledChanged() |
| void | mouseHoverEventsEnabledChanged() |
Protected Functions
| virtual QQuickCPainterRenderer * | createItemRenderer() const = 0 |
Reimplemented Protected Functions
| virtual QQuickRhiItemRenderer * | createRenderer() override |
Property Documentation
acceptedButtons : Qt::MouseButtons
This property holds the mouse buttons that the item reacts to. The default value is Qt.LeftButton.
To accept all buttons use Qt.AllButtons.
Access functions:
| Qt::MouseButtons | acceptedButtons() const |
| void | setAcceptedButtons(Qt::MouseButtons buttons) |
Notifier signal:
| void | acceptedButtonsChanged() |
[read-only] backendName : QString
Get name of used QCPainter RHI backend.
Access functions:
| QString | backendName() const |
Notifier signal:
| void | backendNameChanged() |
fillColor : QColor
This property holds the color to use for filling the item ie. the item background.
The default color is black.
Access functions:
| QColor | fillColor() const |
| void | setFillColor(const QColor &color) |
Notifier signal:
| void | fillColorChanged() |
mouseEventsEnabled : bool
This property defines if item should accept mouse events. The default value is false.
Access functions:
| bool | mouseEventsEnabled() const |
| void | setMouseEventsEnabled(bool enabled) |
Notifier signal:
| void | mouseEventsEnabledChanged() |
mouseHoverEventsEnabled : bool
This property defines if item should accept mouse hover events. The default value is false.
This is basically QML property for accessing QQuickItem::acceptHoverEvents()
Access functions:
| bool | mouseHoverEventsEnabled() const |
| void | setMouseHoverEventsEnabled(bool enabled) |
Notifier signal:
| void | mouseHoverEventsEnabledChanged() |
Member Function Documentation
QQuickCPainterItem::QQuickCPainterItem(QQuickItem *parent = nullptr)
Constructs a QQuickCPainterItem with the given parent item.
[override virtual noexcept] QQuickCPainterItem::~QQuickCPainterItem()
Destroys the QQuickCPainterItem.
Qt::MouseButtons QQuickCPainterItem::acceptedButtons() const
Returns currently accepted mouse buttons.
Note: Getter function for property acceptedButtons.
See also setAcceptedButtons().
QString QQuickCPainterItem::backendName() const
Returns used RHI rendering backend name. See QRhi::backendName()
To affect which backend is used, configure the RHI backend of the Qt application e.g. with QSG_RHI_BACKEND.
Note: Getter function for property backendName.
[pure virtual protected] QQuickCPainterRenderer *QQuickCPainterItem::createItemRenderer() const
Implement this method to (re)create painter for this item. The painter class should be inherited from QQuickCPainterRenderer. QQuickCPainterItem takes the ownership of the created object and deletes it when needed.
Example code:
QQuickCPainterRenderer* MyItem::createItemRenderer() const { return new MyItemPainter(); }
QColor QQuickCPainterItem::fillColor() const
Returns the current fill color.
Note: Getter function for property fillColor.
See also setFillColor().
bool QQuickCPainterItem::mouseEventsEnabled() const
Returns true when mouse events for the item are enabled.
Note: Getter function for property mouseEventsEnabled.
See also setMouseEventsEnabled().
bool QQuickCPainterItem::mouseHoverEventsEnabled() const
Returns true when mouse hover events for the item are enabled.
Note: Getter function for property mouseHoverEventsEnabled.
See also setMouseHoverEventsEnabled().
void QQuickCPainterItem::setAcceptedButtons(Qt::MouseButtons buttons)
Set which mouse buttons are accepted (meaning listened). The default value is Qt::LeftButton.
Note: Setter function for property acceptedButtons.
See also acceptedButtons().
void QQuickCPainterItem::setFillColor(const QColor &color)
Set the fill color to color. This color will be used to draw the background of the item. The default color is black.
Note: When setting the fill color to not fully opaque (alpha channel less than 255), remember to set also alphaBlending to true.
Note: Setter function for property fillColor.
See also fillColor() and QQuickRhiItem::alphaBlending.
void QQuickCPainterItem::setMouseEventsEnabled(bool enabled)
Enable or disabled receiving mouse events depending on enabled. The default value is false, so to receive mouse event they need to be enabled first. Once enabled, QQuickCPainterRenderer::mouseEvent() gets called for all events.
Note: Setter function for property mouseEventsEnabled.
See also mouseEventsEnabled().
void QQuickCPainterItem::setMouseHoverEventsEnabled(bool enabled)
Enable or disabled receiving mouse hover events depending on enabled. The default value is false, so to receive mouse hover event they need to be enabled first. Once enabled, QQuickItem hover events (hoverEnterEvent(), hoverMoveEvent() and hoverLeaveEvent()) event handles will get called.
Note: Setter function for property mouseHoverEventsEnabled.
See also mouseHoverEventsEnabled().
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.