aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@sletta.org>2015-11-26 11:28:07 +0100
committerGunnar Sletta <gunnar@sletta.org>2015-11-30 07:25:44 +0000
commit4ce41d7fdcb07b515f9466c8d532b7f737aa24c9 (patch)
tree9ee10fa252200fa88346c4589c588cb9de16c8c8
parentcf59a0acaee9b47bd371dd3ab8f0a6bd1f5b6d35 (diff)
docfix: Make it clearer how Context2D relates to Canvas
Change-Id: Id64aff29ef8bc7cbb4f7fc46b1a0d30a47585055 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 6ef2d6123b..f0a56867f1 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -222,6 +222,9 @@ QQuickCanvasItemPrivate::~QQuickCanvasItemPrivate()
operations. The Canvas output may be saved as an image file or serialized
to a URL.
+ Rendering to the Canvas is done using a Context2D object, usually as a
+ result of the \l paint signal.
+
To define a drawing area in the Canvas item set the \c width and \c height
properties. For example, the following code creates a Canvas item which
has a drawing area with a height of 100 pixels and width of 200 pixels:
@@ -231,6 +234,11 @@ QQuickCanvasItemPrivate::~QQuickCanvasItemPrivate()
id: mycanvas
width: 100
height: 200
+ onPaint: {
+ var ctx = getContext("2d");
+ ctx.fillStyle = Qt.rgba(1, 0, 0, 1);
+ ctx.fillRect(0, 0, width, height);
+ }
}
\endqml