Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

Canvas Module

The canvas module provides a highly optimized 2D graphic area called QCanvas. The canvas can contain an arbitrary number of QCanvasItems. Canvas items can have an arbitrary shape, size and content, can be freely moved around in the canvas, and can be checked for collisions. Canvas items can be set to move across the canvas automatically and animated canvas items are supported with QCanvasSprite. (If you require 3D graphics see Qt's OpenGL module.)

The canvas module uses a document/view model. The QCanvasView class is used to show a particular view of a canvas. Multiple views can operate on the same canvas at the same time. Every view can use an arbitrary transformation matrix on the canvas which makes it easy to implement features such as zooming.

Screenshot of a canvas

Qt provides a number of predefined QCanvas items as listed below.

The two classes QCanvasPixmap and QCanvasPixmapArray are used by QCanvasSprite to show animated and moving pixmaps on the canvas.

More specialized items can be created by inheriting from one of the canvas item classes. It is easiest to inherit from one of QCanvasItem's derived classes (usually QCanvasPolygonalItem) rather than inherit QCanvasItem directly.

See examples/canvas for an example that shows off some of QCanvas's capabilities.

Copyright © 2007 TrolltechTrademarks
Qt 3.3.8