The QPen class defines how a QPainter should draw lines and outlines of shapes. More...
List of all member functions.
A pen has a style, a width and a color.
The pen style defines the line type. The default pen style is
Setting the style to
NoPen tells the painter to not draw lines or
The pen width defines the line width. The default line width is 0, which draws a 1-pixel line very fast, but with lower precision 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.
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: progress/progress.cpp desktop/desktop.cpp
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.
See also: setWidth(), setStyle() and setColor().
Constructs a pen which is a copy of p.
Destroys the pen.
Returns the pen color.
See also: setColor().
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==().
Assigns c to this 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.
See also: operator!=().
Sets the pen color to c.
See also: color().
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 and returns a reference to the stream.
The serialization format is:
Reads a pen from the stream and returns a reference to the stream.
Search the documentation, FAQ, qt-interest archive and more (uses
This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.
|Copyright © 1999 Troll Tech||Trademarks|
Qt version 2.0.2