Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QPen Class Reference

List of all members.

Detailed Description

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

A pen has a style(), width(), brush(), capStyle() and joinStyle().

The pen style defines the line type. The brush is used to fill strokes generated with the pen. Use the QBrush class to specify fill styles. The cap style determines the line end caps that can be drawn using QPainter, while the join style describes how joins between two lines are drawn. The pen width can be specified in both integer (width()) and floating point (widthF()) precision. A line width of zero indicates a cosmetic pen. This means that the pen width is always drawn one pixel wide, independent of the {QPainter::Coordinate Transformations}{transformation} set on the painter.

The various settings can easily be modified using the corresponding setStyle(), setWidth(), setBrush(), setCapStyle() and setJoinStyle() functions (note that the painter's pen must be reset when altering the pen's properties).

For example:

        QPainter painter(this);
        QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin);

which is equivalent to

        QPainter painter(this);
        QPen pen();  // creates a default pen



The default pen is a solid black brush with 0 width, square cap style (Qt::SquareCap), and bevel join style (Qt::BevelJoin).

In addition QPen provides the color() and setColor() convenience functions to extract and set the color of the pen's brush, respectively. Pens may also be compared and streamed.

For more information about painting in general, see {The Paint System} documentation.

Definition at line 43 of file qpen.h.

Public Member Functions

QBrush brush () const
Qt::PenCapStyle capStyle () const
QColor color () const
QVector< qreal > dashPattern () const
bool isDetached ()
bool isSolid () const
Qt::PenJoinStyle joinStyle () const
qreal miterLimit () const
 operator QVariant () const
bool operator!= (const QPen &p) const
QPenoperator= (const QPen &pen)
bool operator== (const QPen &p) const
 QPen (const QPen &pen)
 QPen (const QBrush &brush, qreal width, Qt::PenStyle s=Qt::SolidLine, Qt::PenCapStyle c=Qt::SquareCap, Qt::PenJoinStyle j=Qt::BevelJoin)
 QPen (const QColor &color)
 QPen (Qt::PenStyle)
 QPen ()
void setBrush (const QBrush &brush)
void setCapStyle (Qt::PenCapStyle pcs)
void setColor (const QColor &color)
void setDashPattern (const QVector< qreal > &pattern)
void setJoinStyle (Qt::PenJoinStyle pcs)
void setMiterLimit (qreal limit)
void setStyle (Qt::PenStyle)
void setWidth (int width)
void setWidthF (qreal width)
Qt::PenStyle style () const
int width () const
qreal widthF () const
 ~QPen ()

Private Member Functions

void detach ()

Private Attributes

class QPenPrivate * d


Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QPen &)
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, QPen &)
class QPainter

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index