📄 qcanvasview.3qt
字号:
'\" t.TH QCanvasView 3qt "9 December 2002" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQCanvasView \- On-screen view of a QCanvas.SH SYNOPSIS\fC#include <qcanvas.h>\fR.PPInherits QScrollView..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQCanvasView\fR ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )".br.ti -1c.BI "\fBQCanvasView\fR ( QCanvas * canvas, QWidget * parent = 0, const char * name = 0, WFlags f = 0 )".br.ti -1c.BI "\fB~QCanvasView\fR ()".br.ti -1c.BI "QCanvas * \fBcanvas\fR () const".br.ti -1c.BI "void \fBsetCanvas\fR ( QCanvas * canvas )".br.ti -1c.BI "const QWMatrix & \fBworldMatrix\fR () const".br.ti -1c.BI "const QWMatrix & \fBinverseWorldMatrix\fR () const".br.ti -1c.BI "bool \fBsetWorldMatrix\fR ( const QWMatrix & wm )".br.in -1c.SS "Protected Members".in +1c.ti -1c.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 DESCRIPTIONThe QCanvasView class provides an on-screen view of a QCanvas..PPA QCanvasView is widget which provides a view of a QCanvas..PPIf you want users to be able to interact with a canvas view, subclass QCanvasView. You might then reimplement QScrollView::contentsMousePressEvent() for example:.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) {.br if ( (*it)->rtti() == QCanvasRectangle::RTTI ).br qDebug("A QCanvasRectangle lies somewhere at this point");.br }.br }.br.fi.PPSet the canvas that the view shows with setCanvas() and retrieve the canvas which the view is showing with canvas()..PPA transformation matrix can be used to transform the view of the canvas in various ways, for example, zooming in or out or rotating. For example:.PP.nf.br QWMatrix wm;.br wm.scale( 2, 2 ); // Zooms in by 2 times.br wm.rotate( 90 ); // Rotates 90 degrees counter clockwise.br // around the origin..br wm.translate( 0, -canvas->height() );.br // moves the canvas down so what was visible.br // before is still visible..br myCanvasView->setWorldMatrix( wm );.br.fi.PPUse 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()..PPExample:.PPThe 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..PP.nf.br QRect rc = QRect( myCanvasView->contentsX(), myCanvasView->contentsY(),.br myCanvasView->visibleWidth(), myCanvasView->visibleHeight() );.br QRect canvasRect = myCanvasView->inverseWorldMatrix().mapRect(rc);.br.fi.PPSee 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 will need to call setCanvas() to display a canvas..SH "QCanvasView::QCanvasView ( QCanvas * canvas, QWidget * parent = 0, const char * name = 0, WFlags f = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPConstructs 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..PPReimplemented from QScrollView..SH "const QWMatrix & QCanvasView::inverseWorldMatrix () const"Returns a reference to the inverse of the canvas view's current transformation matrix..PPSee also setWorldMatrix() and worldMatrix()..SH "void QCanvasView::setCanvas ( QCanvas * canvas )"Sets the canvas that the QCanvasView is showing to the canvas \fIcanvas\fR..SH "bool QCanvasView::setWorldMatrix ( const QWMatrix & wm )"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)..PPWhen you use this, you should note that the performance of the QCanvasView will decrease considerably..PPReturns FALSE if \fIwm\fR is not invertable; otherwise returns TRUE..PPSee also worldMatrix(), inverseWorldMatrix(), and QWMatrix::isInvertible()..PPExample: canvas/canvas.cpp..SH "QSize QCanvasView::sizeHint () const\fC [virtual protected]\fR"Suggests a size sufficient to view the entire canvas..SH "const QWMatrix & QCanvasView::worldMatrix () const"Returns a reference to the canvas view's current transformation matrix..PPSee also setWorldMatrix() and inverseWorldMatrix()..PPExample: canvas/canvas.cpp..SH "SEE ALSO".BR http://doc.trolltech.com/qcanvasview.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qcanvasview.3qt) and the Qtversion (3.1.1).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -