The QPen class defines how the QPainter should draw lines and outlines of shapes. (details) (complete member list)
#include <qpen.h>
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 not so accurate. Setting the line width to 1 or more draws lines that are precise, but drawing is slower.
The line color defines the color of lines and text. The default line color is black. The QColor documentation contains a list of standard colors.
Use the QBrush class for specifying fill styles.
Example of how to use a pen:
QPainter painter;
QPen pen( red ); // red solid line, 0 width
painter.begin( &anyPaintDevice ); // paint widget, pixmap etc.
painter.setPen( pen ); // sets the red pen
painter.drawRect( 40,30, 200,100 ); // draw 200x100 rect at (40,30)
painter.pen().setColor( blue ); // change pen color to blue
painter.drawLine( 40,30, 240,130 ); // draw diagonal in rectangle
painter.end(); // painting done
The setStyle() function has a list of pen styles.
Constructs a default black solid line pen with 0 width.
Constructs a pen black with 0 width and a specified style.
See also: setStyle().
Constructs a pen with a specified color, width and style.
Constructs a pen which is a shallow copy of p.
Destroys the pen.
Returns the pen color.
See also: setColor().
Returns a deep copy of the pen.
Detaches from shared pen data to makes sure that this pen is the only one referring the data.
If multiple pens share common data, this pen dereferences the data and gets a copy of the data. Nothing will be done if there is just a single reference.
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 and colors.
Assigns a shallow copy of p to the pen and returns a reference to this pen.
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.
Sets the pen color to c.
See also: color().
Sets the pen style to s.
The pen styles are:
See also: style().
Sets the pen width to w.
See also: width().
Returns the pen style.
See also: setStyle().
Returns the pen width.
See also: setWidth().
Writes a pen to the stream.
Reads a pen from the stream.
This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.
It was generated from the following files: