QPen(3qt)

NAME
QPen - Defines how a QPainter should draw lines and outlines of shapes

SYNOPSIS

#include <qpen.h>

  Public Members
QPen ()
QPen ( PenStyle )
QPen ( const QColor & color, uint width=0, PenStyle style=SolidLine )
QPen ( const QPen & )
~QPen ()
QPen& operator= ( const QPen & )
PenStyle style () const
void setStyle ( PenStyle )
uint width () const
void setWidth ( uint )
const QColor& color () const
void setColor ( const QColor & )
bool operator== ( const QPen & p ) const
bool operator!= ( const QPen & p ) const

RELATED FUNCTION DOCUMENTATION
(Note that these are not member functions.)
QDataStream & operator<< (QDataStream & s, const QPen & p)
QDataStream & operator>> (QDataStream & s, QPen & p)

DESCRIPTION
The QPen class defines how a QPainter should draw lines and outlines of shapes.

A pen has a style, a width and a color.

The pen style defines the line type. The default pen style is SolidPen. Setting the style to NoPen tells the painter to not draw lines or outlines.

The pen width defines the line width. The default line width is 0, which draws a 1-pixel line very fast, but with lower presicion than with a line width of 1. Setting the line width to 1 or more draws lines that are precise, but drawing is slower.

The pen color defines the color of lines and text. The default line color is black. The QColor documentation lists predefined colors.

Use the QBrush class for specifying fill styles.

Example:

    QPainter painter;
    QPen     pen( red, 2 );             // red solid line, 2 pixel width
    painter.begin( &anyPaintDevice );   // paint something
    painter.setPen( pen );              // set the red, fat pen
    painter.drawRect( 40,30, 200,100 ); // draw rectangle
    painter.setPen( blue );             // set blue pen, 0 pixel width
    painter.drawLine( 40,30, 240,130 ); // draw diagonal in rectangle
    painter.end();                      // painting done

See the setStyle() function for a complete list of pen styles.

See also: QPainter and QPainter::setPen().

Examples: tictac/tictac.cpp desktop/desktop.cpp progress/progress.cpp

MEMBER FUNCTION DOCUMENTATION

QPen::QPen ()
Constructs a default black solid line pen with 0 width.

QPen::QPen ( PenStyle style )
Constructs a pen black with 0 width and a specified style.

See also: setStyle().

QPen::QPen ( const QColor & color, uint width=0, PenStyle style=SolidLine )
Constructs a pen with a specified color, width and style.

See also: setWidth(), setStyle() and setColor().

QPen::QPen ( const QPen & p )
Constructs a pen which is a copy of p.

QPen::~QPen ()
Destroys the pen.

const QColor & QPen::color () const
Returns the pen color.

See also: setColor().

bool QPen::operator!= ( const QPen & p ) const
Returns TRUE if the pen is different from p, or FALSE if the pens are equal.

Two pens are different if they have different styles, widths or colors.

See also: operator==().

QPen & QPen::operator= ( const QPen & p )
Assigns c to this pen and returns a reference to this pen.

bool QPen::operator== ( const QPen & p ) const
Returns TRUE if the pen is equal to p, or FALSE if the pens are different.

Two pens are equal if they have equal styles, widths and colors.

See also: operator!=().

void QPen::setColor ( const QColor & c )
Sets the pen color to c.

See also: color().

Examples: progress/progress.cpp

void QPen::setStyle ( PenStyle s )
Sets the pen style to s.

The pen styles are:

NoPen no outline is drawn.

SolidLine solid line (default).

DashLine - - - (dashes) line.

DotLine * * * (dots) line.

DashDotLine - * - * line.

DashDotDotLine - ** - ** line.

See also: style().

void QPen::setWidth ( uint w )
Sets the pen width to w.

See also: width().

Examples: progress/progress.cpp

PenStyle QPen::style () const
Returns the pen style.

See also: setStyle().

uint QPen::width () const
Returns the pen width.

See also: setWidth().

RELATED FUNCTION DOCUMENTATION

QDataStream & operator<< (QDataStream & s, const QPen & p)
Writes a pen to the stream and returns a reference to the stream.

The serialization format is:

1   The pen style (UINT8)

2   The pen width (UINT8)

3   The pen color (QColor)

QDataStream & operator>> (QDataStream & s, QPen & p)
Reads a pen from the stream and returns a reference to the stream.

SEE ALSO
http://www.troll.no/qt/qpen.html

COPYRIGHT
Copyright 1992-1997 Troll Tech AS. See the LICENSE file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.