返回介绍

QCanvasRectangle Class

发布于 2019-10-04 14:58:42 字数 3531 浏览 973 评论 0 收藏 0

The QCanvasRectangle class provides a rectangle on a QCanvas. More...

#include <qcanvas.h>

Inherits QCanvasPolygonalItem.

List of all member functions.

Public Members

  • QCanvasRectangle ( QCanvas*canvas )
  • QCanvasRectangle ( constQRect&r, QCanvas*canvas )
  • QCanvasRectangle ( intx, inty, intwidth, intheight, QCanvas*canvas )
  • ~QCanvasRectangle ()
  • int width () const
  • int height () const
  • void setSize ( intwidth, intheight )
  • QSize size () const
  • QRect rect () const
  • virtual int rtti () const

Protected Members

  • virtual void drawShape ( QPainter&p )
  • virtual QPointArray chunks () const

Detailed Description

The QCanvasRectangle class provides a rectangle on a QCanvas.

This item paints a single rectangle which may have any pen() and brush(), but may not be tilted/rotated. For rotated rectangles, use QCanvasPolygon.

The rectangle's size and initial position can be set in the constructor. The size can be set or changed later using setSize(). Use height() and width() to retrieve the rectangle's dimensions.

The rectangle can be drawn on a painter with drawShape().

Like any other canvas item rectangles can be moved with QCanvasItem::move() and QCanvasItem::moveBy(), or by setting coordinates with QCanvasItem::setX(), QCanvasItem::setY() and QCanvasItem::setZ().

See also Graphics Classes and Image Processing Classes.


Member Function Documentation

QCanvasRectangle::QCanvasRectangle ( QCanvas*canvas )

Constructs a rectangle at position (0,0) with both width and height set to 32 pixels on canvas.

QCanvasRectangle::QCanvasRectangle ( constQRect&r, QCanvas*canvas )

Constructs a rectangle positioned and sized by r on canvas.

QCanvasRectangle::QCanvasRectangle ( intx, inty, intwidth, intheight, QCanvas*canvas )

Constructs a rectangle at position (x, y) and size width by height, on canvas.

QCanvasRectangle::~QCanvasRectangle ()

Destroys the rectangle.

QPointArray QCanvasRectangle::chunks () const [virtual protected]

Simply calls QCanvasItem::chunks().

void QCanvasRectangle::drawShape ( QPainter&p ) [virtual protected]

Draws the rectangle on painter p.

Example: canvas/canvas.cpp.

Reimplemented from QCanvasPolygonalItem.

int QCanvasRectangle::height () const

Returns the height of the rectangle.

QRect QCanvasRectangle::rect () const

Returns the integer-converted x(), y() position and size() of the rectangle as a QRect.

int QCanvasRectangle::rtti () const [virtual]

Returns 5 (QCanvasItem::Rtti_Rectangle).

See also QCanvasItem::rtti().

Reimplemented from QCanvasPolygonalItem.

void QCanvasRectangle::setSize ( intwidth, intheight )

Sets the width and height of the rectangle.

QSize QCanvasRectangle::size () const

Returns the width() and height() of the rectangle.

See also rect() and setSize().

int QCanvasRectangle::width () const

Returns the width of the rectangle.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文