.BI "virtual void \fBdrawContents\fR ( QPainter * p, int cx, int cy, int cw, int ch )"
.br
.ti -1c
.BI "virtual QSize \fBsizeHint\fR () const"
.br
.in -1c
.SH DESCRIPTION
The QCanvasView class provides an on-screen view of a QCanvas.
.PP
A QCanvasView is widget which provides a view of a QCanvas.
.PP
If you want users to be able to interact with a canvas view, subclass QCanvasView. You might then reimplement QScrollView::contentsMousePressEvent(). For example, assuming no transformation matrix is set:
.PP
.nf
.br
void MyCanvasView::contentsMousePressEvent( QMouseEvent* e )
.br
{
.br
QCanvasItemList l = canvas()->collisions(e->pos());
.br
for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
Use setWorldMatrix() to set the canvas view's world matrix: you must ensure that the world matrix is invertible. The current world matrix is retrievable with worldMatrix(), and its inversion is retrievable with inverseWorldMatrix().
.PP
Example:
.PP
The following code finds the part of the canvas that is visible in this view, i.e. the bounding rectangle of the view in canvas coordinates.
See also QWMatrix, QPainter::setWorldMatrix(), Graphics Classes, and Image Processing Classes.
.PP
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QCanvasView::QCanvasView ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )"
Constructs a QCanvasView with parent \fIparent\fR, and name \fIname\fR, using the widget flags \fIf\fR. The canvas view is not associated with a canvas, so you must to call setCanvas() to view a canvas.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Constructs a QCanvasView which views canvas \fIcanvas\fR, with parent \fIparent\fR, and name \fIname\fR, using the widget flags \fIf\fR.
.SH "QCanvasView::~QCanvasView ()"
Destroys the canvas view. The associated canvas is \fInot\fR deleted.
.SH "QCanvas * QCanvasView::canvas () const"
Returns a pointer to the canvas which the QCanvasView is currently showing.
.SH "void QCanvasView::drawContents ( QPainter * p, int cx, int cy, int cw, int ch )\fC [virtual protected]\fR"
Repaints part of the QCanvas that the canvas view is showing starting at \fIcx\fR by \fIcy\fR, with a width of \fIcw\fR and a height of \fIch\fR using the painter \fIp\fR.
.PP
\fBWarning:\fR When double buffering is enabled, drawContents() will not respect the current settings of the painter when setting up the painter for the double buffer (e.g., viewport() and window()). Also, be aware that QCanvas::update() bypasses drawContents(), which means any reimplementation of drawContents() is not called.
Sets the transformation matrix of the QCanvasView to \fIwm\fR. The matrix must be invertible (i.e. if you create a world matrix that zooms out by 2 times, then the inverse of this matrix is one that will zoom in by 2 times).
.PP
When you use this, you should note that the performance of the QCanvasView will decrease considerably.
.PP
Returns FALSE if \fIwm\fR is not invertable; otherwise returns TRUE.
.PP
See also worldMatrix(), inverseWorldMatrix(), and QWMatrix::isInvertible().