diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-01-19 10:32:37 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-01-19 10:32:37 +0100 |
commit | 81b3d791b5920832eefb616720bccf5cd386cd57 (patch) | |
tree | 9c89f63c0977c5c7ae09d8a35b505dd09e88a64f /src/quick/items/context2d/qquickcanvasitem.cpp | |
parent | 7c9e51e7e7b358fb9c4829ee8f02918ec4cfd016 (diff) | |
parent | d1461c8429c7b6f9e9442f319d5a49b7e7a5b67d (diff) |
Merge remote-tracking branch 'origin/5.5' into 5.6
Change-Id: Ieb48911638b5c1acdfd4dee8aa19dca9be99a1f6
Diffstat (limited to 'src/quick/items/context2d/qquickcanvasitem.cpp')
-rw-r--r-- | src/quick/items/context2d/qquickcanvasitem.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index 9abca59b1c..9fb49f9c9e 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 |