1QCanvasView(3qt)                                              QCanvasView(3qt)
2
3
4

NAME

6       QCanvasView - On-screen view of a QCanvas
7

SYNOPSIS

9       #include <qcanvas.h>
10
11       Inherits QScrollView.
12
13   Public Members
14       QCanvasView ( QWidget * parent = 0, const char * name = 0, WFlags f = 0
15           )
16       QCanvasView ( QCanvas * canvas, QWidget * parent = 0, const char * name
17           = 0, WFlags f = 0 )
18       ~QCanvasView ()
19       QCanvas * canvas () const
20       void setCanvas ( QCanvas * canvas )
21       const QWMatrix & worldMatrix () const
22       const QWMatrix & inverseWorldMatrix () const
23       bool setWorldMatrix ( const QWMatrix & wm )
24
25   Protected Members
26       virtual void drawContents ( QPainter * p, int cx, int cy, int cw, int
27           ch )
28       virtual QSize sizeHint () const
29

DESCRIPTION

31       The QCanvasView class provides an on-screen view of a QCanvas.
32
33       A QCanvasView is widget which provides a view of a QCanvas.
34
35       If you want users to be able to interact with a canvas view, subclass
36       QCanvasView. You might then reimplement
37       QScrollView::contentsMousePressEvent(). For example, assuming no
38       transformation matrix is set:
39
40           void MyCanvasView::contentsMousePressEvent( QMouseEvent* e )
41           {
42               QCanvasItemList l = canvas()->collisions(e->pos());
43               for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
44                   if ( (*it)->rtti() == QCanvasRectangle::RTTI )
45                       qDebug("A QCanvasRectangle lies somewhere at this point");
46               }
47           }
48
49       The canvas view shows canvas canvas(); this can be changed using
50       setCanvas().
51
52       A transformation matrix can be used to transform the view of the canvas
53       in various ways, for example, zooming in or out or rotating. For
54       example:
55
56           QWMatrix wm;
57           wm.scale( 2, 2 );   // Zooms in by 2 times
58           wm.rotate( 90 );    // Rotates 90 degrees counter clockwise
59                               // around the origin.
60           wm.translate( 0, -canvas->height() );
61                               // moves the canvas down so what was visible
62                               // before is still visible.
63           myCanvasView->setWorldMatrix( wm );
64
65       Use setWorldMatrix() to set the canvas view's world matrix: you must
66       ensure that the world matrix is invertible. The current world matrix is
67       retrievable with worldMatrix(), and its inversion is retrievable with
68       inverseWorldMatrix().
69
70       Example:
71
72       The following code finds the part of the canvas that is visible in this
73       view, i.e. the bounding rectangle of the view in canvas coordinates.
74
75           QRect rc = QRect( myCanvasView->contentsX(), myCanvasView->contentsY(),
76                               myCanvasView->visibleWidth(), myCanvasView->visibleHeight() );
77           QRect canvasRect = myCanvasView->inverseWorldMatrix().mapRect(rc);
78
79       See also QWMatrix, QPainter::setWorldMatrix(), Graphics Classes, and
80       Image Processing Classes.
81

MEMBER FUNCTION DOCUMENTATION

QCanvasView::QCanvasView ( QWidget * parent = 0, const char * name = 0, WFlags

84       f = 0 )
85       Constructs a QCanvasView with parent parent, and name name, using the
86       widget flags f. The canvas view is not associated with a canvas, so you
87       must to call setCanvas() to view a canvas.
88

QCanvasView::QCanvasView ( QCanvas * canvas, QWidget * parent = 0, const char

90       * name = 0, WFlags f = 0 )
91       This is an overloaded member function, provided for convenience. It
92       behaves essentially like the above function.
93
94       Constructs a QCanvasView which views canvas canvas, with parent parent,
95       and name name, using the widget flags f.
96

QCanvasView::~QCanvasView ()

98       Destroys the canvas view. The associated canvas is not deleted.
99

QCanvas * QCanvasView::canvas () const

101       Returns a pointer to the canvas which the QCanvasView is currently
102       showing.
103

void QCanvasView::drawContents ( QPainter * p, int cx, int cy, int cw, int ch

105       ) [virtual protected]
106       Repaints part of the QCanvas that the canvas view is showing starting
107       at cx by cy, with a width of cw and a height of ch using the painter p.
108
109       Warning: When double buffering is enabled, drawContents() will not
110       respect the current settings of the painter when setting up the painter
111       for the double buffer (e.g., viewport() and window()). Also, be aware
112       that QCanvas::update() bypasses drawContents(), which means any
113       reimplementation of drawContents() is not called.
114
115       See also QCanvas::setDoubleBuffering().
116
117       Reimplemented from QScrollView.
118

const QWMatrix & QCanvasView::inverseWorldMatrix () const

120       Returns a reference to the inverse of the canvas view's current
121       transformation matrix.
122
123       See also setWorldMatrix() and worldMatrix().
124

void QCanvasView::setCanvas ( QCanvas * canvas )

126       Sets the canvas that the QCanvasView is showing to the canvas canvas.
127

bool QCanvasView::setWorldMatrix ( const QWMatrix & wm )

129       Sets the transformation matrix of the QCanvasView to wm. The matrix
130       must be invertible (i.e. if you create a world matrix that zooms out by
131       2 times, then the inverse of this matrix is one that will zoom in by 2
132       times).
133
134       When you use this, you should note that the performance of the
135       QCanvasView will decrease considerably.
136
137       Returns FALSE if wm is not invertable; otherwise returns TRUE.
138
139       See also worldMatrix(), inverseWorldMatrix(), and
140       QWMatrix::isInvertible().
141
142       Example: canvas/canvas.cpp.
143

QSize QCanvasView::sizeHint () const [virtual protected]

145       Suggests a size sufficient to view the entire canvas.
146

const QWMatrix & QCanvasView::worldMatrix () const

148       Returns a reference to the canvas view's current transformation matrix.
149
150       See also setWorldMatrix() and inverseWorldMatrix().
151
152       Example: canvas/canvas.cpp.
153
154

SEE ALSO

156       http://doc.trolltech.com/qcanvasview.html
157       http://www.trolltech.com/faq/tech.html
158
160       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
161       license file included in the distribution for a complete license
162       statement.
163

AUTHOR

165       Generated automatically from the source code.
166

BUGS

168       If you find a bug in Qt, please report it as described in
169       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
170       help you. Thank you.
171
172       The definitive Qt documentation is provided in HTML format; it is
173       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
174       web browser. This man page is provided as a convenience for those users
175       who prefer man pages, although this format is not officially supported
176       by Trolltech.
177
178       If you find errors in this manual page, please report them to qt-
179       bugs@trolltech.com.  Please include the name of the manual page
180       (qcanvasview.3qt) and the Qt version (3.3.8).
181
182
183
184Trolltech AS                    2 February 2007               QCanvasView(3qt)
Impressum