qcanvasview.html
来自「QT 下载资料仅供参考」· HTML 代码 · 共 175 行
HTML
175 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/canvas/qcanvas.cpp:3295 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QCanvasView Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCanvasView Class Reference<br><small>[<a href="canvas.html">canvas module</a>]</small></h1><p>The QCanvasView class provides an on-screen view of a QCanvas.<a href="#details">More...</a><p><tt>#include <<a href="qcanvas-h.html">qcanvas.h</a>></tt><p>Inherits <a href="qscrollview.html">QScrollView</a>.<p><a href="qcanvasview-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QCanvasView"><b>QCanvasView</b></a> ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )</div></li><li><div class=fn><a href="#QCanvasView-2"><b>QCanvasView</b></a> ( QCanvas * canvas, QWidget * parent = 0, const char * name = 0, WFlags f = 0 )</div></li><li><div class=fn><a href="#~QCanvasView"><b>~QCanvasView</b></a> ()</div></li><li><div class=fn>QCanvas * <a href="#canvas"><b>canvas</b></a> () const</div></li><li><div class=fn>void <a href="#setCanvas"><b>setCanvas</b></a> ( QCanvas * canvas )</div></li><li><div class=fn>const QWMatrix & <a href="#worldMatrix"><b>worldMatrix</b></a> () const</div></li><li><div class=fn>const QWMatrix & <a href="#inverseWorldMatrix"><b>inverseWorldMatrix</b></a> () const</div></li><li><div class=fn>bool <a href="#setWorldMatrix"><b>setWorldMatrix</b></a> ( const QWMatrix & wm )</div></li></ul><h2>Protected Members</h2><ul><li><div class=fn>virtual void <a href="#drawContents"><b>drawContents</b></a> ( QPainter * p, int cx, int cy, int cw, int ch )</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QCanvasView class provides an on-screen view of a <a href="qcanvas.html">QCanvas</a>.<p> A QCanvasView is widget which provides a view of a QCanvas.<p> If you want users to be able to interact with a canvas view,subclass QCanvasView. You might then reimplement<a href="qscrollview.html#contentsMousePressEvent">QScrollView::contentsMousePressEvent</a>() for example:<p> <pre> void MyCanvasView::contentsMousePressEvent( <a href="qmouseevent.html">QMouseEvent</a>* e ) { <a href="qcanvasitemlist.html">QCanvasItemList</a> l = <a href="#canvas">canvas</a>()->collisions(e-><a href="qmouseevent.html#pos">pos</a>()); for (QCanvasItemList::Iterator it=l.<a href="qvaluelist.html#begin">begin</a>(); it!=l.<a href="qvaluelist.html#end">end</a>(); ++it) { if ( (*it)->rtti() == QCanvasRectangle::RTTI ) <a href="qapplication.html#qDebug">qDebug</a>("A QCanvasRectangle lies somewhere at this point"); } } </pre> <p> Set the canvas that the view shows with <a href="#setCanvas">setCanvas</a>() and retrieve thecanvas which the view is showing with <a href="#canvas">canvas</a>().<p> A transformation matrix can be used to transform the view of thecanvas in various ways, for example, zooming in or out or rotating.For example:<p> <pre> <a href="qwmatrix.html">QWMatrix</a> wm; wm.<a href="qwmatrix.html#scale">scale</a>( 2, 2 ); // Zooms in by 2 times wm.<a href="qwmatrix.html#rotate">rotate</a>( 90 ); // Rotates 90 degrees counter clockwise // around the origin. wm.<a href="qwmatrix.html#translate">translate</a>( 0, -canvas->height() ); // moves the canvas down so what was visible // before is still visible. myCanvasView->setWorldMatrix( wm ); </pre> <p> Use <a href="#setWorldMatrix">setWorldMatrix</a>() to set the canvas view's world matrix: you mustensure that the world matrix is invertible. The current world matrixis retrievable with <a href="#worldMatrix">worldMatrix</a>(), and its inversion is retrievablewith <a href="#inverseWorldMatrix">inverseWorldMatrix</a>().<p> Example:<p> The following code finds the part of the canvas that is visible inthis view, i.e. the bounding rectangle of the view in canvas coordinates.<p> <pre> <a href="qrect.html">QRect</a> rc = QRect( myCanvasView->contentsX(), myCanvasView->contentsY(), myCanvasView->visibleWidth(), myCanvasView->visibleHeight() ); <a href="qrect.html">QRect</a> canvasRect = myCanvasView->inverseWorldMatrix().mapRect(rc); </pre> <p> <p>See also <a href="qwmatrix.html">QWMatrix</a>, <a href="qpainter.html#setWorldMatrix">QPainter::setWorldMatrix</a>(), <a href="graphics.html">Graphics Classes</a> and <a href="images.html">Image Processing Classes</a>.<p> <hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QCanvasView"></a>QCanvasView::QCanvasView ( <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0, WFlags f = 0 )</h3>Constructs a QCanvasView with parent <em>parent</em>, and name <em>name</em>,using the widget flags <em>f</em>. The canvas view is not associated with acanvas, so you will need to call <a href="#setCanvas">setCanvas</a>() to display a canvas.<h3 class=fn><a name="QCanvasView-2"></a>QCanvasView::QCanvasView ( <a href="qcanvas.html">QCanvas</a> * canvas, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0, WFlags f = 0 )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Constructs a QCanvasView which views canvas <em>canvas</em>, with parent <em>parent</em>, and name <em>name</em>, using the widget flags <em>f</em>.<h3 class=fn><a name="~QCanvasView"></a>QCanvasView::~QCanvasView ()</h3>Destroys the canvas view. The associated canvas is <em>not</em> deleted.<h3 class=fn><a href="qcanvas.html">QCanvas</a> * <a name="canvas"></a>QCanvasView::canvas () const</h3><p> Returns a pointer to the canvas which the QCanvasView is currentlyshowing.<h3 class=fn>void <a name="drawContents"></a>QCanvasView::drawContents ( <a href="qpainter.html">QPainter</a> * p, int cx, int cy, int cw, int ch )<tt> [virtual protected]</tt></h3>Repaints part of the <a href="qcanvas.html">QCanvas</a> that the canvas view is showingstarting at <em>cx</em> by <em>cy</em>, with a width of <em>cw</em> and a height of <em>ch</em> using the painter <em>p</em>.<p>Reimplemented from <a href="qscrollview.html#drawContents">QScrollView</a>.<h3 class=fn>const <a href="qwmatrix.html">QWMatrix</a> & <a name="inverseWorldMatrix"></a>QCanvasView::inverseWorldMatrix () const</h3>Returns a reference to the inverse of the canvas view's currenttransformation matrix.<p> <p>See also <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#worldMatrix">worldMatrix</a>().<h3 class=fn>void <a name="setCanvas"></a>QCanvasView::setCanvas ( <a href="qcanvas.html">QCanvas</a> * canvas )</h3>Sets the canvas that the QCanvasView is showing to the canvas <em>canvas</em>.<h3 class=fn>bool <a name="setWorldMatrix"></a>QCanvasView::setWorldMatrix ( const <a href="qwmatrix.html">QWMatrix</a> & wm )</h3>Sets the transformation matrix of the QCanvasView to <em>wm</em>. Thematrix must be invertible (i.e. if you create a world matrix thatzooms out by 2 times, then the inverse of this matrix is one that willzoom in by 2 times).<p> When you use this, you should note that the performance of theQCanvasView will decrease considerably.<p> Returns FALSE if <em>wm</em> is not invertable; otherwise returns TRUE.<p> <p>See also <a href="#worldMatrix">worldMatrix</a>(), <a href="#inverseWorldMatrix">inverseWorldMatrix</a>() and <a href="qwmatrix.html#isInvertible">QWMatrix::isInvertible</a>().<p>Example: <a href="canvas-example.html#x2706">canvas/canvas.cpp</a>.<h3 class=fn>const <a href="qwmatrix.html">QWMatrix</a> & <a name="worldMatrix"></a>QCanvasView::worldMatrix () const</h3>Returns a reference to the canvas view's current transformation matrix.<p> <p>See also <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#inverseWorldMatrix">inverseWorldMatrix</a>().<p>Example: <a href="canvas-example.html#x2707">canvas/canvas.cpp</a>.<!-- eof --><hr><p>This file is part of the <a href="index.html">Qt toolkit</a>.Copyright © 1995-2002<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright © 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?