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

📄 qcanvasitem.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
📖 第 1 页 / 共 2 页
字号:
.PPSee also QCanvas::advance() and setVelocity()..PPExample: canvas/canvas.cpp..PPReimplemented in QCanvasSprite..SH "bool QCanvasItem::animated () const"Returns TRUE is the canvas item is in motion; otherwise returns FALSE..PPSee also setVelocity() and setAnimated()..SH "QRect QCanvasItem::boundingRect () const\fC [pure virtual]\fR"Returns the bounding rectangle in pixels that the canvas item covers..PPSee also boundingRectAdvanced()..PPReimplemented in QCanvasSprite, QCanvasPolygonalItem, and QCanvasText..SH "QRect QCanvasItem::boundingRectAdvanced () const\fC [virtual]\fR"Returns the bounding rectangle of pixels that the canvas item \fIwill\fR cover after advance(1) is called..PPSee also boundingRect()..SH "QCanvas * QCanvasItem::canvas () const"Returns the canvas containing the canvas item..SH "bool QCanvasItem::collidesWith ( const QCanvasItem * other ) const\fC [pure virtual]\fR"Returns TRUE if the canvas item will collide with the \fIother\fR item \fIafter\fR they have moved by their current velocities; otherwise returns FALSE..PPSee also collisions()..PPExample: canvas/canvas.cpp..SH "QCanvasItemList QCanvasItem::collisions ( bool exact ) const"Returns the list of canvas items that this canvas item has collided with..PPA collision is generally defined as occurring when the pixels of one item draw on the pixels of another item, but not all subclasses are so precise. Also, since pixel-wise collision detection can be slow, this function works in either exact or inexact mode, according to the \fIexact\fR parameter..PPIf \fIexact\fR is TRUE, the canvas items returned have been accurately tested for collision with the canvas item..PPIf \fIexact\fR is FALSE, the canvas items returned are \fInear\fR the canvas item. You can test the canvas items returned using collidesWith() if any are interesting collision candidates. By using this approach, you can ignore some canvas items for which collisions are not relevant..PPThe returned list is a list of QCanvasItems, but often you will need to cast the items to their subclass types. The safe way to do this is to use rtti() before casting. This provides some of the functionality of the standard C++ dynamic cast operation even on compilers where dynamic casts are not available..PPNote that a canvas item may be `on' a canvas, e.g. it was created with the canvas as parameter, even though its coordinates place it beyond the edge of the canvas's area. Collision detection only works for canvas items which are wholly or partly within the canvas's area..PPNote that if items have a velocity (see setVelocity()), then collision testing is done based on where the item \fIwill\fR be when it moves, not its current location. For example, a "ball" item doesn't need to actually embed into a "wall" item before a collision is detected. For items without velocity, plain intersection is used..SH "void QCanvasItem::draw ( QPainter & painter )\fC [pure virtual]\fR"This abstract virtual function draws the canvas item using \fIpainter\fR..PPReimplemented in QCanvasSprite, QCanvasPolygonalItem, and QCanvasText..SH "bool QCanvasItem::enabled () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPUse isEnabled() instead..SH "void QCanvasItem::hide ()"Shorthand for setVisible(FALSE)..SH "bool QCanvasItem::isActive () const"Returns TRUE if the QCanvasItem is active; otherwise returns FALSE..SH "bool QCanvasItem::isEnabled () const"Returns TRUE if the QCanvasItem is enabled; otherwise returns FALSE..SH "bool QCanvasItem::isSelected () const"Returns TRUE if the canvas item is selected; otherwise returns FALSE..SH "bool QCanvasItem::isVisible () const"Returns TRUE if the canvas item is visible; otherwise returns FALSE..PPNote that in this context TRUE does \fInot\fR mean that the canvas item is currently in a view, merely that if a view is showing the area where the canvas item is positioned, and the item is not obscured by items with higher z values, and the view is not obscured by overlaying windows, it would be visible..PPSee also setVisible() and z()..SH "void QCanvasItem::move ( double x, double y )"Moves the canvas item to the absolute position (\fIx\fR, \fIy\fR)..PPExample: canvas/canvas.cpp..SH "void QCanvasItem::moveBy ( double dx, double dy )\fC [virtual]\fR"Moves the canvas item relative to its current position by (\fIdx\fR, \fIdy\fR)..PPExample: canvas/canvas.cpp..SH "int QCanvasItem::rtti () const\fC [virtual]\fR"Returns 0 (QCanvasItem::Rtti_Item)..PPMake your derived classes return their own values for rtti(), so that you can distinguish between objects returned by QCanvas::at(). You should use values greater than 1000 to allow for extensions to this class..PPOveruse of this functionality can damage it's extensibility. For example, once you have identified a base class of a QCanvasItem found by QCanvas::at(), cast it to that type and call meaningful methods rather than acting upon the object based on its rtti value..PPFor example:.PP.nf.br    QCanvasItem* item;.br    // Find an item, eg. with QCanvasItem::collisions()..br    ....br    if (item->rtti() == MySprite::RTTI ) {.br        MySprite* s = (MySprite*)item;.br        if (s->isDamagable()) s->loseHitPoints(1000);.br        if (s->isHot()) myself->loseHitPoints(1000);.br        ....br    }.fi.PPExample: canvas/canvas.cpp..PPReimplemented in QCanvasSprite, QCanvasPolygonalItem, and QCanvasText..SH "bool QCanvasItem::selected () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPUse isSelected() instead..SH "void QCanvasItem::setActive ( bool yes )\fC [virtual]\fR"Sets the active flag of the item to \fIyes\fR. If this changes the item's active state the item will be redrawn when QCanvas::update() is next called..PPThe QCanvas, QCanvasItem and the Qt-supplied QCanvasItem subclasses do not make use of this value. The setActive() function is supplied because many applications need it, but it is up to you how you use the isActive() value..SH "void QCanvasItem::setAnimated ( bool y )\fC [virtual]\fR"Sets the canvas item to be in motion if \fIy\fR is TRUE, or not if \fIy\fR is FALSE. The speed and direction of the motion is set with setVelocity(), or setXVelocity() and setYVelocity()..PPSee also advance() and QCanvas::advance()..SH "void QCanvasItem::setCanvas ( QCanvas * c )\fC [virtual]\fR"Sets the QCanvas upon which the canvas item is to be drawn to \fIc\fR..PPSee also canvas()..SH "void QCanvasItem::setEnabled ( bool yes )\fC [virtual]\fR"Sets the enabled flag of the item to \fIyes\fR. If this changes the item's enabled state the item will be redrawn when QCanvas::update() is next called..PPThe QCanvas, QCanvasItem and the Qt-supplied QCanvasItem subclasses do not make use of this value. The setEnabled() function is supplied because many applications need it, but it is up to you how you use the isEnabled() value..SH "void QCanvasItem::setSelected ( bool yes )\fC [virtual]\fR"Sets the selected flag of the item to \fIyes\fR. If this changes the item's selected state the item will be redrawn when QCanvas::update() is next called..PPThe QCanvas, QCanvasItem and the Qt-supplied QCanvasItem subclasses do not make use of this value. The setSelected() function is supplied because many applications need it, but it is up to you how you use the isSelected() value..SH "void QCanvasItem::setVelocity ( double vx, double vy )\fC [virtual]\fR"Sets the canvas item to be in motion, moving by \fIvx\fR and \fIvy\fR pixels in the horizontal and vertical directions respectively..PPSee also advance()..SH "void QCanvasItem::setVisible ( bool yes )\fC [virtual]\fR"Makes the canvas item visible if \fIyes\fR is TRUE, or invisible if \fIyes\fR is FALSE. The change takes effect when QCanvas::update() is next called..SH "void QCanvasItem::setX ( double x )"Moves the canvas item so that its x-position is \fIx\fR..PPSee also x() and move()..PPExample: chart/chartform_canvas.cpp..SH "void QCanvasItem::setXVelocity ( double vx )"Sets the horizontal component of the canvas item's velocity to \fIvx\fR..SH "void QCanvasItem::setY ( double y )"Moves the canvas item so that its y-position is \fIy\fR..PPSee also y() and move()..PPExample: chart/chartform_canvas.cpp..SH "void QCanvasItem::setYVelocity ( double vy )"Sets the vertical component of the canvas item's velocity to \fIvy\fR..SH "void QCanvasItem::setZ ( double z )"Sets the z index of the canvas item to \fIz\fR. Higher-z items obscure (are in front of) lower-z items..PPSee also z() and move()..PPExamples:.)l canvas/canvas.cpp and chart/chartform_canvas.cpp..SH "void QCanvasItem::show ()"Shorthand for setVisible(TRUE)..PPExamples:.)l canvas/canvas.cpp and chart/chartform_canvas.cpp..SH "void QCanvasItem::update ()\fC [protected]\fR"Call this function to repaint the canvas's changed chunks..SH "bool QCanvasItem::visible () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPUse isVisible() instead..SH "double QCanvasItem::x () const"Returns the horizontal position of the canvas item. Note that subclasses often have an origin other than the top-left corner..PPExample: canvas/canvas.cpp..SH "double QCanvasItem::xVelocity () const"Returns the horizontal velocity component of the canvas item..SH "double QCanvasItem::y () const"Returns the vertical position of the canvas item. Note that subclasses often have an origin other than the top-left corner..PPExample: canvas/canvas.cpp..SH "double QCanvasItem::yVelocity () const"Returns the vertical velocity component of the canvas item..SH "double QCanvasItem::z () const"Returns the z index of the canvas item, which is used for visualorder: higher-z items obscure (are in front of) lower-z items..SH "SEE ALSO".BR http://doc.trolltech.com/qcanvasitem.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 (qcanvasitem.3qt) and the Qtversion (3.1.1).

⌨️ 快捷键说明

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