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.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKPAINTEDITEM_P_H
6#define QQUICKPAINTEDITEM_P_H
7
8#include <QtQuick/qquickitem.h>
9#include <QtGui/qcolor.h>
10#include <QtCore/qrect.h>
11
13
14class QQuickPaintedItemPrivate;
15class QPainter;
16class Q_QUICK_EXPORT QQuickPaintedItem : public QQuickItem
17{
18 Q_OBJECT
19
20 Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize NOTIFY contentsSizeChanged)
21 Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
22 Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged)
23 Q_PROPERTY(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged)
24 Q_PROPERTY(QSize textureSize READ textureSize WRITE setTextureSize NOTIFY textureSizeChanged)
25
26 QML_NAMED_ELEMENT(PaintedItem)
27 QML_ADDED_IN_VERSION(2, 0)
28 QML_UNCREATABLE("Cannot create instance of abstract class PaintedItem.")
29
30public:
31 explicit QQuickPaintedItem(QQuickItem *parent = nullptr);
32 ~QQuickPaintedItem() override;
33
34 enum RenderTarget {
35 Image,
36 FramebufferObject,
37 InvertedYFramebufferObject
38 };
39 Q_ENUM(RenderTarget)
40
41 enum PerformanceHint {
42 FastFBOResizing = 0x1
43 };
44 Q_DECLARE_FLAGS(PerformanceHints, PerformanceHint)
45 Q_FLAG(PerformanceHints)
46
47 void update(const QRect &rect = QRect());
48
49 bool opaquePainting() const;
50 void setOpaquePainting(bool opaque);
51
52 bool antialiasing() const;
53 void setAntialiasing(bool enable);
54
55 bool mipmap() const;
56 void setMipmap(bool enable);
57
58 PerformanceHints performanceHints() const;
59 void setPerformanceHint(PerformanceHint hint, bool enabled = true);
60 void setPerformanceHints(PerformanceHints hints);
61
62 QRectF contentsBoundingRect() const;
63
64 QSize contentsSize() const;
65 void setContentsSize(const QSize &);
66 void resetContentsSize();
67
68 qreal contentsScale() const;
69 void setContentsScale(qreal);
70
71 QSize textureSize() const;
72 void setTextureSize(const QSize &size);
73
74 QColor fillColor() const;
75 void setFillColor(const QColor&);
76
77 RenderTarget renderTarget() const;
78 void setRenderTarget(RenderTarget target);
79
80 virtual void paint(QPainter *painter) = 0;
81
82 bool isTextureProvider() const override;
83 QSGTextureProvider *textureProvider() const override;
84
85Q_SIGNALS:
86 void fillColorChanged();
87 void contentsSizeChanged();
88 void contentsScaleChanged();
89 void renderTargetChanged();
90 void textureSizeChanged();
91
92protected:
93 QQuickPaintedItem(QQuickPaintedItemPrivate &dd, QQuickItem *parent = nullptr);
94 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
95 void releaseResources() override;
96 void itemChange(ItemChange, const ItemChangeData &) override;
97
98private Q_SLOTS:
99 void invalidateSceneGraph();
100
101private:
102 Q_DISABLE_COPY(QQuickPaintedItem)
103 Q_DECLARE_PRIVATE(QQuickPaintedItem)
104};
105
106Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPaintedItem::PerformanceHints)
107
108QT_END_NAMESPACE
109
110#endif // QQUICKPAINTEDITEM_P_H
friend class QPainter
QMap< int, QQuickPixmap * > frameMap
The QQuickPaintedItem class provides a way to use the QPainter API in the QML Scene Graph.
QT_REQUIRE_CONFIG(animation)
QT_REQUIRE_CONFIG(quick_animatedimage)