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

Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends

QPen Class Reference

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

Collaboration diagram for QPen:
Collaboration graph

List of all members.

Public Types

typedef QPenPrivateDataPtr

Public Member Functions

QBrush brush () const
Qt::PenCapStyle capStyle () const
QColor color () const
qreal dashOffset () const
QVector< qreal > dashPattern () const
DataPtrdata_ptr ()
bool isCosmetic () 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 QBrush &brush, qreal width, Qt::PenStyle s=Qt::SolidLine, Qt::PenCapStyle c=Qt::SquareCap, Qt::PenJoinStyle j=Qt::BevelJoin)
 QPen (Qt::PenStyle)
 QPen (const QPen &pen)
 QPen ()
 QPen (const QColor &color)
void setBrush (const QBrush &brush)
void setCapStyle (Qt::PenCapStyle pcs)
void setColor (const QColor &color)
void setCosmetic (bool cosmetic)
void setDashOffset (qreal doffset)
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 QPenPrivated


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

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:

doc/src/snippets/code/src_gui_painting_qpen.cpp 0

which is equivalent to

doc/src/snippets/code/src_gui_painting_qpen.cpp 1

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 64 of file qpen.h.

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

Generated by  Doxygen 1.6.0   Back to index