QCanvasRectangle Class

Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QCanvasRectangle Class Reference
[canvas module]

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 ( const QRect & r, QCanvas * canvas )
- QCanvasRectangle ( int x, int y, int width, int height, QCanvas * canvas )
- ~QCanvasRectangle ()
- int width () const
- int height () const
- void setSize ( int width, int height )
- 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 ( const QRect & r, QCanvas * canvas )

Constructs a rectangle positioned and sized by r on canvas.

### QCanvasRectangle::QCanvasRectangle ( int x, int y, int width, int height, 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 ( int width, int height )

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.

This file is part of the Qt toolkit. Copyright © 1995-2005 Trolltech. All Rights Reserved.