⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qcanvas.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
📖 第 1 页 / 共 2 页
字号:
l - l. 0 1 2 3 4 5 6.TE.fi</center>.PPThe QCanvas is initially sized to show exactly the given number of tiles horizontally and vertically. If it is resized to be larger, the entire matrix of tiles will be repeated as much as necessary to cover the area. If it is smaller, tiles to the right and bottom will not be visible..PPSee also setTiles()..SH "QCanvas::~QCanvas ()\fC [virtual]\fR"Destroys the canvas and all the canvas's canvas items..SH "void QCanvas::advance ()\fC [virtual slot]\fR"Moves all QCanvasItem::animated() canvas items on the canvas and refreshes all changes to all views of the canvas. (An `animated' item is an item that is in motion; see setVelocity().).PPThe advance takes place in two phases. In phase 0, the QCanvasItem::advance() function of each QCanvasItem::animated() canvas item is called with paramater 0. Then all these canvas items are called again, with parameter 1. In phase 0, the canvas items should not change position, merely examine other items on the canvas for which special processing is required, such as collisions between items. In phase 1, all canvas items should change positions, ignoring any other items on the canvas. This two-phase approach allows for considerations of "fairness", although no QCanvasItem subclasses supplied with Qt do anything interesting in phase 0..PPThe canvas can be configured to call this function periodically with setAdvancePeriod()..PPSee also update()..SH "QCanvasItemList QCanvas::allItems ()"Returns a list of all items in the canvas..SH "QColor QCanvas::backgroundColor () const"Returns the color set by setBackgroundColor(). By default, this is white..PPThis function is not a reimplementation of QWidget::backgroundColor() (QCanvas is not a subclass of QWidget), but all QCanvasViews that are viewing the canvas will set their backgrounds to this color..PPSee also setBackgroundColor() and backgroundPixmap()..SH "QPixmap QCanvas::backgroundPixmap () const"Returns the pixmap set by setBackgroundPixmap(). By default, this is a null pixmap..PPSee also setBackgroundPixmap() and backgroundColor()..SH "int QCanvas::chunkSize () const"Returns the chunk size of the canvas..PPSee also retune()..SH "QCanvasItemList QCanvas::collisions ( const QPoint & p ) const"Returns a list of canvas items that collide with the point \fIp\fR. The list is ordered by z coordinates, from highest z coordinate (front-most item) to lowest z coordinate (rear-most item)..SH "QCanvasItemList QCanvas::collisions ( const QRect & r ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns a list of items which collide with the rectangle \fIr\fR. The list is ordered by z coordinates, from highest z coordinate (front-most item) to lowest z coordinate (rear-most item)..SH "QCanvasItemList QCanvas::collisions ( const QPointArray & chunklist, const QCanvasItem * item, bool exact ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns a list of canvas items which intersect with the chunks listed in \fIchunklist\fR, excluding \fIitem\fR. If \fIexact\fR is TRUE, only those which actually QCanvasItem::collidesWith() \fIitem\fR are returned; otherwise canvas items are included just for being in the chunks..PPThis is a utility function mainly used to implement the simpler QCanvasItem::collisions() function..SH "void QCanvas::drawArea ( const QRect & clip, QPainter * painter, bool dbuf = FALSE )"Paints all canvas items that are in the area \fIclip\fR to \fIpainter\fR, using double-buffering if \fIdbuf\fR is TRUE..PPe.g. to print the canvas to a printer:.PP.nf.br  QPrinter pr;.br  if ( pr.setup() ) {.br    QPainter p(&pr);.br    canvas.drawArea( canvas.rect(), &p );.br  }.br.fi.PPExample: canvas/canvas.cpp..SH "void QCanvas::drawBackground ( QPainter & painter, const QRect & clip )\fC [virtual protected]\fR"This virtual function is called for all updates of the canvas. It renders any background graphics using the painter \fIpainter\fR, in the area \fIclip\fR. If the canvas has a background pixmap or a tiled background, that graphic is used, otherwise the canvas is cleared using the background color..PPIf the graphics for an area change, you must explicitly call setChanged(const QRect&) for the result to be visible when update() is next called..PPSee also setBackgroundColor(), setBackgroundPixmap(), and setTiles()..SH "void QCanvas::drawForeground ( QPainter & painter, const QRect & clip )\fC [virtual protected]\fR"This virtual function is called for all updates of the canvas. It renders any foreground graphics using the painter \fIpainter\fR, in the area \fIclip\fR..PPIf the graphics for an area change, you must explicitly call setChanged(const QRect&) for the result to be visible when update() is next called..PPThe default is to draw nothing..SH "int QCanvas::height () const"Returns the height of the canvas, in pixels..PPExample: canvas/canvas.cpp..SH "bool QCanvas::onCanvas ( int x, int y ) const"Returns TRUE if the pixel position (\fIx\fR, \fIy\fR) is on the canvas; otherwise returns FALSE..PPSee also validChunk()..SH "bool QCanvas::onCanvas ( const QPoint & p ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns TRUE if the pixel position \fIp\fR is on the canvas; otherwise returns FALSE..PPSee also validChunk()..SH "QRect QCanvas::rect () const"Returns a rectangle the size of the canvas..SH "void QCanvas::resize ( int w, int h )\fC [virtual]\fR"Changes the size of the canvas to have a width of \fIw\fR and a height of \fIh\fR. This is a slow operation..PPExamples:.)l canvas/canvas.cpp and chart/chartform.cpp..SH "void QCanvas::resized ()\fC [signal]\fR"This signal is emitted whenever the canvas is resized. Each QCanvasView connects to this signal to keep the scrollview size correct..SH "void QCanvas::retune ( int chunksze, int mxclusters = 100 )\fC [virtual]\fR"Change the efficiency tuning parameters to \fImxclusters\fR clusters, each of size \fIchunksze\fR. This is a slow operation if there are many objects on the canvas..PPThe canvas is divided into chunks which are rectangular areas of the canvas \fIchunksze\fR wide by \fIchunksze\fR high. Use a chunk size which is about the average size of the canvas items. If you choose a chunk size which is too small it will increase the amount of calculation required when drawing since each change will affect many chunks. If you choose a chunk size which is too large the amount of drawing required will increase because for each change, a lot of drawing will be required since there will be many (unchanged) canvas items which are in the same chunk as the changed canvas items..PPInternally, a canvas uses a low-resolution "chunk matrix" to keep track of all the items in the canvas. A 64x64 chunk matrix is the default for a 1024x1024 pixel canvas, where each chunk collects canvas items in a 16x16 pixel square. This default is also affected by setTiles(). You can tune this default with this function. For example if you have a very large canvas and want to trade off speed for memory then you might set the chunk size to 32 or 64..PPThe \fImxclusters\fR argument is the number of rectangular groups of chunks that will be separately drawn. If the canvas has a large number of small, dispersed items, this should be about that number. Our testing suggests that a large number of clusters is almost always best..SH "void QCanvas::setAdvancePeriod ( int ms )\fC [virtual]\fR"Sets the canvas to call advance() every \fIms\fR milliseconds. Any previous setting by setAdvancePeriod() or setUpdatePeriod() is overridden..PPIf \fIms\fR is less than 0 advancing will be stopped..PPExample: canvas/main.cpp..SH "void QCanvas::setAllChanged ()\fC [virtual]\fR"Marks the whole canvas as changed. All views of the canvas will be entirely redrawn when update() is called next..SH "void QCanvas::setBackgroundColor ( const QColor & c )\fC [virtual]\fR"Sets the solid background to be the color \fIc\fR..PPSee also backgroundColor(), setBackgroundPixmap(), and setTiles()..SH "void QCanvas::setBackgroundPixmap ( const QPixmap & p )\fC [virtual]\fR"Sets the solid background to be the pixmap \fIp\fR repeated as necessary to cover the entire canvas..PPSee also backgroundPixmap(), setBackgroundColor(), and setTiles()..SH "void QCanvas::setChanged ( const QRect & area )\fC [virtual]\fR"Marks \fIarea\fR as changed. This area will be redrawn in all views that are showing it when update() is called next..SH "void QCanvas::setDoubleBuffering ( bool y )\fC [virtual]\fR"If \fIy\fR is TRUE (the default) double-buffering is switched on; otherwise double-buffering is switched off..PPTurning off double-buffering causes the redrawn areas to flicker a bit and also gives a (usually small) performance improvement..PPExample: canvas/canvas.cpp..SH "void QCanvas::setTile ( int x, int y, int tilenum )\fC [virtual]\fR"Sets the tile at (\fIx\fR, \fIy\fR) to use tile number \fItilenum\fR, which is an index into the tile pixmaps. The canvas will update appropriately when update() is next called..PPThe images are taken from the pixmap set by setTiles() and are arranged left to right, (and in the case of pixmaps that have multiple rows of tiles, top to bottom), with tile 0 in the top-left corner, tile 1 next to the right, and so on, e.g..PP<center>.nf.TSl - l. 0 1 2 3 4 5 6.TE.fi</center>.PPSee also tile() and setTiles()..SH "void QCanvas::setTiles ( QPixmap p, int h, int v, int tilewidth, int tileheight )\fC [virtual]\fR"Sets the QCanvas to be composed of \fIh\fR tiles horizontally and \fIv\fR tiles vertically. Each tile will be an image \fItilewidth\fR by \fItileheight\fR pixels from pixmap \fIp\fR..PPThe pixmap \fIp\fR is a list of tiles, arranged left to right, (and in the case of pixmaps that have multiple rows of tiles, top to bottom), with tile 0 in the top-left corner, tile 1 next to the right, and so on, e.g..PP<center>.nf.TSl - l. 0 1 2 3 4 5 6.TE.fi</center>.PPIf the canvas is larger than the matrix of tiles, the entire matrix is repeated as necessary to cover the whole canvas. If it is smaller, tiles to the right and bottom are not visible..PPThe width and height of \fIp\fR must be a multiple of \fItilewidth\fR and \fItileheight\fR. If they are not the function will do nothing..SH "void QCanvas::setUnchanged ( const QRect & area )\fC [virtual]\fR"Marks \fIarea\fR as \fIunchanged\fR. The area will \fInot\fR be redrawn in the views for the next update(), unless it is marked or changed again before the next call to update()..SH "void QCanvas::setUpdatePeriod ( int ms )\fC [virtual]\fR"Sets the canvas to call update() every \fIms\fR milliseconds. Any previous setting by setAdvancePeriod() or setUpdatePeriod() is overridden..PPIf \fIms\fR is less than 0 automatic updating will be stopped..SH "QSize QCanvas::size () const"Returns the size of the canvas, in pixels..SH "int QCanvas::tile ( int x, int y ) const"Returns the tile at position (\fIx\fR, \fIy\fR). Initially, all tiles are 0..PPThe parameters must be within range, i.e. 0 < \fIx\fR < tilesHorizontally() and 0 < \fIy\fR < tilesVertically()..PPSee also setTile()..SH "int QCanvas::tileHeight () const"Returns the height of each tile..SH "int QCanvas::tileWidth () const"Returns the width of each tile..SH "int QCanvas::tilesHorizontally () const"Returns the number of tiles horizontally..SH "int QCanvas::tilesVertically () const"Returns the number of tiles vertically..SH "void QCanvas::update ()\fC [virtual slot]\fR"Repaints changed areas in all views of the canvas..PPSee also advance()..SH "bool QCanvas::validChunk ( int x, int y ) const"Returns TRUE if the chunk position (\fIx\fR, \fIy\fR) is on the canvas; otherwise returns FALSE..PPSee also onCanvas()..SH "bool QCanvas::validChunk ( const QPoint & p ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns TRUE if the chunk position \fIp\fR is on the canvas; otherwise returns FALSE..PPSee also onCanvas()..SH "int QCanvas::width () const"Returns the width of the canvas, in pixels..PPExample: canvas/canvas.cpp..SH "SEE ALSO".BR http://doc.trolltech.com/qcanvas.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 (qcanvas.3qt) and the Qtversion (3.1.1).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -