- Qt 6.12
- Qt Canvas Painter
- Qt Canvas Painter | Commercial or GPLv3

# Qt Canvas Painter

The Qt Canvas Painter module provides classes for hardware-accelerated imperative 2D painting. This painting API is available for both Qt Quick and Qt Widgets, and can also be used directly with QRhi. The API design generally follows HTML canvas 2d context, with some reductions and some additions.

Compared to QPainter, the Qt Canvas Painter is more compact and has fewer abstractions, aiming to perform optimally on QRhi. Qt Canvas Painter is designed for GPU rendering and does not have a CPU backend as QPainter does.

## Using the Module

### C++ API

Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake.

### QML API

The QML types of the module are available through the `QtCanvas2D` import. To use the types, add the following import statement to your .qml file:

     import QtCanvas2D

#### Building with CMake

Use the `find_package()` command to locate the needed module component in the `Qt6` package:

     find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)
     target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter)

For more details, see the Build with CMake overview.

Shaders used with QCanvasCustomBrush are added to the project with the qt_add_custom_brush_shaders CMake function.

## Class Reference

- Qt Canvas Painter C++ Classes
- Qt Canvas2D QML types

## Examples

All examples

## Licenses and Attributions

Qt Canvas Painter runtime library is available under commercial licenses from The Qt Company. In addition, it is available under the GNU General Public License, version 3.

See Qt Licensing for further details.

Furthermore, Qt Canvas Painter in 6.12.0 may contain third party modules under the following permissive licenses:

NanoVG, version f93799c | zlib License