QtCanvasRectangle Class Reference

The QtCanvasRectangle class provides a rectangle on a QtCanvas. More...

#include <QtCanvasRectangle>

Inherits QtCanvasPolygonalItem.

Public Functions

Protected Functions


Detailed Description

The QtCanvasRectangle class provides a rectangle on a QtCanvas.

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

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 QtCanvasItem::move() and QtCanvasItem::moveBy(), or by setting coordinates with QtCanvasItem::setX(), QtCanvasItem::setY() and QtCanvasItem::setZ().


Member Function Documentation

QtCanvasRectangle::QtCanvasRectangle ( QtCanvas * canvas )

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

QtCanvasRectangle::QtCanvasRectangle ( const QRect & r, QtCanvas * canvas )

Constructs a rectangle positioned and sized by r on canvas.

QtCanvasRectangle::QtCanvasRectangle ( int x, int y, int width, int height, QtCanvas * canvas )

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

QtCanvasRectangle::~QtCanvasRectangle ()

Destroys the rectangle.

QPolygon QtCanvasRectangle::chunks () const   [virtual protected]

Simply calls QtCanvasItem::chunks().

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

Draws the rectangle on painter p.

Reimplemented from QtCanvasPolygonalItem.

int QtCanvasRectangle::height () const

Returns the height of the rectangle.

QRect QtCanvasRectangle::rect () const

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

int QtCanvasRectangle::rtti () const   [virtual]

Returns 5 (QtCanvasItem::Rtti_Rectangle).

Reimplemented from QtCanvasItem.

See also QtCanvasItem::rtti().

void QtCanvasRectangle::setSize ( int width, int height )

Sets the width and height of the rectangle.

See also size().

QSize QtCanvasRectangle::size () const

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

See also rect() and setSize().

int QtCanvasRectangle::width () const

Returns the width of the rectangle.


Copyright © 2005 Trolltech Trademarks