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

QPainterPath Class Reference

The QPainterPath class specifies a vectorial graphical shape. More...

#include <QPainterPath>

List of all members.

Public Types

Public Functions


Detailed Description

The QPainterPath class specifies a vectorial graphical shape.

A painter path is an object composed of a number of graphical building blocks, such as rectangles, ellipses, lines and curves. A painter path can be used for filling, outlining, and for clipping. The main advantage of painter paths over normal drawing operations is that it is possible to build up non-linear shapes which can be drawn later one go.

Building blocks can be joined in closed sub-paths, such as a rectangle or an ellipse, or they can exist independently as unclosed sub-paths, although an unclosed path will not be filled.

Below is a code example on how a path can be used. The painter in this case has a pen width of 3 and a light blue brush. We first add a rectangle, which becomes a closed sub-path. We then add two bezier curves, and finally draw the entire path.

    QPainterPath path;
    path.addRect(20, 20, 60, 60);
    path.addBezier(0, 0,  99, 0,  50, 50,  99, 99);
    path.addBezier(99, 99,  0, 99,  50, 50,  0, 0);
    painter.drawPath(path);

Member Type Documentation

enum QPainterPath::FillMode

Specifies which method should be used to fill the path.

QPainterPath::OddEvenSpecifies that the region is filled using the odd even fill rule. With this rule, one determines wheter a point is inside the path as follows: Draw a horizontal line from the point to outside the path and count the number of intersections. If the number of intersections is an odd number the point is inside the path. This mode is the default.
QPainterPath::WindingSpecifies that the region is filled using the non zero winding rule. With this rule, one determines wheter a point is inside the path as follows: Draw a horizontal line from the path to the outside of the path. Determine the direction of the path in each intersection point, up or down. The winding number is determined by summing the direction of each intersection. If the number is non zero, the point is inside the path. This fill mode can also in most cases be considered as the intersection of closed shapes.

Member Function Documentation

QPainterPath::QPainterPath ()

Creates a new empty QPainterPath.

QPainterPath::QPainterPath ( const QPainterPath & other )

QPainterPath::~QPainterPath ()

void QPainterPath::addArc ( const QRect & rect, int startAngle, int arcLength )

void QPainterPath::addArc ( int x, int y, int w, int h, int startAngle, int arcLength )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QPainterPath::addBezier ( const QPoint & p1, const QPoint & p2, const QPoint & p3, const QPoint & p4 )

Adds a Bezier curve with control points p1, p2, p3, and p4, to the path.

void QPainterPath::addBezier ( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QPainterPath::addBezier ( const QPointArray & pa )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Adds the Bezier curve specified by the point array pa to the path. The point array <b>must</b> contain exactly four points or the function will give a warning and do nothing.

void QPainterPath::addLine ( const QPoint & p1, const QPoint & p2 )

Adds a straight line defined by the start point p1 and the end point p2 to the path.

void QPainterPath::addLine ( int x1, int y1, int x2, int y2 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QPainterPath::addLine ( int x, int y )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QPainterPath::addLine ( const QPoint & p )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Adds a straight line from the last point to point p.

void QPainterPath::addRect ( const QRect & rect )

Adds the given rect to the path. The rect is closed and is not considered to be part of the current subpath.

void QPainterPath::addRect ( int x, int y, int w, int h )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QPainterPath::addRect ( const QPoint & topLeft, const QPoint & bottomRight )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QPainterPath::addRect ( const QPoint & topLeft, const QSize & dimension )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QPainterPath::beginSubpath ()

Begins a new subpath in the existing path. If the path has no elements this function does nothing. If a subpath is already in progress this function does not automatically close it.

See also closeSubpath().

QRect QPainterPath::boundingRect () const

Returns the bounding rectangle of this painter path

void QPainterPath::closeSubpath ()

Closes the current subpath. If the subpath does not contain any elements, the function does nothing. A new subpath is automatically begun when the current subpath is closed.

See also beginSubpath().

FillMode QPainterPath::fillMode () const

Returns the fill mode of the painter path. The default fill mode is OddEven.

See also FillMode and setFillMode.

void QPainterPath::setFillMode ( FillMode fillMode )

QPainterPath & QPainterPath::operator= ( const QPainterPath & other )


Copyright © 2004 Trolltech. Trademarks
Qt 4.0.0-tp1