QPen Class - Qt 3.0.5 Documentation (2024)

previous page next page

Home| AllClasses| MainClasses| Annotated| GroupedClasses| FunctionsQPen Class - Qt 3.0.5 Documentation (1)

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

#include <qpen.h>

Inherits Qt.

List of all member functions.

Public Members

  • QPen ()

  • QPen ( PenStylestyle )

  • QPen ( constQColor&color, uintwidth = 0, PenStylestyle = SolidLine )

  • QPen ( constQColor&cl, uintw, PenStyles, PenCapStylec, PenJoinStylej )

  • QPen ( constQPen&p )

  • ~QPen ()

  • QPen & operator= ( constQPen&p )

  • PenStyle style () const

  • void setStyle ( PenStyles )

  • uint width () const

  • void setWidth ( uintw )

  • const QColor & color () const

  • void setColor ( constQColor&c )

  • PenCapStyle capStyle () const

  • void setCapStyle ( PenCapStylec )

  • PenJoinStyle joinStyle () const

  • void setJoinStyle ( PenJoinStylej )

  • bool operator== ( constQPen&p ) const

  • bool operator!= ( constQPen&p ) const

Related Functions

  • QDataStream & operator<< ( QDataStream&s, constQPen&p )

  • QDataStream & operator>> ( QDataStream&s, QPen&p )

Detailed Description

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

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

The pen style defines the line type. The default pen style is Qt::SolidLine. Setting the style to NoPen tells the painter tonot draw lines or outlines.

When drawing 1 pixel wide diagonal lines you can either use a veryfast algorithm (specified by a line width of 0, which is thedefault), or a slower but more accurate algorithm (specified by aline width of 1). For horizontal and vertical lines a line widthof 0 is the same as a line width of 1. The cap and join style haveno effect on 0-width lines.

The pen color defines the color of lines and text. The defaultline color is black. The QColor documentation lists predefinedcolors.

The cap style defines how the end points of lines are drawn. Thejoin style defines how the joins between two lines are drawn whenmultiple connected lines are drawn (QPainter::drawPolyLine()etc.). The cap and join styles only apply to wide lines, i.e. whenthe width is 1 or greater.

Use the QBrush class to specify fill styles.

Example:

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

See the Qt::PenStyle enum type for a complete list of penstyles.

With reference to the end points of lines, for wide (non-0-width)pens it depends on the cap style whether the end point is drawn ornot. QPainter will try to make sure that the end point is drawnfor 0-width pens, but this cannot be absolutely guaranteed becausethe underlying drawing engine is free to use any (typicallyaccelerated) algorithm for drawing 0-width lines. On all testedsystems, however, the end point of at least all non-diagonal linesare drawn.

A pen's color(), width(), style(), capStyle() and joinStyle() canbe set in the constructor or later with setColor(), setWidth(),setStyle(), setCapStyle() and setJoinStyle(). Pens may also becompared and streamed.

QPen Class - Qt 3.0.5 Documentation (2)

See also QPainter, QPainter::setPen(), Graphics Classes, Image Processing Classes and Implicitly and Explicitly Shared Classes.

Member Function Documentation

QPen::QPen ()

Constructs a default black solid line pen with 0 width, whichrenders lines 1 pixel wide (fast diagonals).

QPen::QPen ( PenStylestyle )

Constructs a black pen with 0 width (fast diagonals) and style style.

See also setStyle().

QPen::QPen ( constQColor&color, uintwidth = 0, PenStylestyle = SolidLine )

Constructs a pen with the specified color, width and style.

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

QPen::QPen ( constQColor&cl, uintw, PenStyles, PenCapStylec, PenJoinStylej )

Constructs a pen with the specified color cl and width w.The pen style is set to s, the pen cap style to c and thepen join style to j.

A line width of 0 will produce a 1 pixel wide line using a fastalgorithm for diagonals. A line width of 1 will also produce a 1pixel wide line, but uses a slower more accurate algorithm fordiagonals. For horizontal and vertical lines a line width of 0 isthe same as a line width of 1. The cap and join style have noeffect on 0-width lines.

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

QPen::QPen ( constQPen&p )

Constructs a pen that is a copy of p.

QPen::~QPen ()

Destroys the pen.

PenCapStyle QPen::capStyle () const

Returns the pen's cap style.

See also setCapStyle().

constQColor& QPen::color () const

Returns the pen color.

See also setColor().

Example: scribble/scribble.h.

PenJoinStyle QPen::joinStyle () const

Returns the pen's join style.

See also setJoinStyle().

bool QPen::operator!= ( constQPen&p ) const

Returns TRUE if the pen is different from p; otherwise returnsFALSE.

Two pens are different if they have different styles, widths orcolors.

See also operator==().

QPen& QPen::operator= ( constQPen&p )

Assigns p to this pen and returns a reference to this pen.

bool QPen::operator== ( constQPen&p ) const

Returns TRUE if the pen is equal to p; otherwise returns FALSE.

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

See also operator!=().

void QPen::setCapStyle ( PenCapStylec )

Sets the pen's cap style to c.

The default value is FlatCap. The cap style has no effect on0-width pens.

QPen Class - Qt 3.0.5 Documentation (3)

Warning: On Windows 95/98 and Macintosh, the cap style setting hasno effect. Wide lines are rendered as if the cap style was SquareCap.

See also capStyle().

Example: themes/wood.cpp.

void QPen::setColor ( constQColor&c )

Sets the pen color to c.

See also color().

Examples: progress/progress.cpp and scribble/scribble.h.

void QPen::setJoinStyle ( PenJoinStylej )

Sets the pen's join style to j.

The default value is MiterJoin. The join style has no effect on0-width pens.

QPen Class - Qt 3.0.5 Documentation (4)

Warning: On Windows 95/98 and Macintosh, the join style settinghas no effect. Wide lines are rendered as if the join style was BevelJoin.

See also joinStyle().

Example: themes/wood.cpp.

void QPen::setStyle ( PenStyles )

Sets the pen style to s.

See the Qt::PenStyle documentation for a list of all thestyles.

Warning: On Windows 95/98 and Macintosh, the style setting (otherthan NoPen and SolidLine) has no effect for lines with widthgreater than 1.

See also style().

Example: chart/chartform_canvas.cpp.

void QPen::setWidth ( uintw )

Sets the pen width to w.

A line width of 0 will produce a 1 pixel wide line using a fastalgorithm for diagonals. A line width of 1 will also produce a 1pixel wide line, but uses a slower more accurate algorithm fordiagonals. For horizontal and vertical lines a line width of 0 isthe same as a line width of 1. The cap and join style have noeffect on 0-width lines.

See also width().

Examples: progress/progress.cpp and scribble/scribble.h.

PenStyle QPen::style () const

Returns the pen style.

See also setStyle().

uint QPen::width () const

Returns the pen width.

See also setWidth().

Example: scribble/scribble.h.

Related Functions

QDataStream& operator<< ( QDataStream&s, constQPen&p )

Writes the pen p to the stream s and returns a reference tothe stream.

See also Format of the QDataStream operators.

QDataStream& operator>> ( QDataStream&s, QPen&p )

Reads a pen from the stream s into p and returns a referenceto the stream.

See also Format of the QDataStream operators.

This file is part of the Qt toolkit.Copyright © 1995-2002Trolltech. All Rights Reserved.

Copyright © 2002TrolltechTrademarks

Qt version 3.0.5

QPen Class - Qt 3.0.5 Documentation (2024)

References

Top Articles
How Noisy Are Parakeets? (Squawking At Night vs. Morning)
Are Parakeets Loud? 9 Noises Explained
Craigslist Free En Dallas Tx
T Mobile Rival Crossword Clue
Housing Intranet Unt
Was sind ACH-Routingnummern? | Stripe
Detroit Lions 50 50
Aces Fmc Charting
Gfs Rivergate
Dc Gas Login
No Hard Feelings Showtimes Near Cinemark At Harlingen
Carolina Aguilar Facebook
Tvtv.us Duluth Mn
Violent Night Showtimes Near Amc Fashion Valley 18
Divina Rapsing
Shasta County Most Wanted 2022
Water Trends Inferno Pool Cleaner
Uconn Health Outlook
Finalize Teams Yahoo Fantasy Football
Atdhe Net
Used Safari Condo Alto R1723 For Sale
Providence Medical Group-West Hills Primary Care
Anotherdeadfairy
Surplus property Definition: 397 Samples | Law Insider
California Online Traffic School
Mineral Wells Skyward
Nk 1399
What Is a Yurt Tent?
Pronóstico del tiempo de 10 días para San Josecito, Provincia de San José, Costa Rica - The Weather Channel | weather.com
Delete Verizon Cloud
100 Gorgeous Princess Names: With Inspiring Meanings
Rogold Extension
Human Unitec International Inc (HMNU) Stock Price History Chart & Technical Analysis Graph - TipRanks.com
One Credit Songs On Touchtunes 2022
Unlock The Secrets Of "Skip The Game" Greensboro North Carolina
Hotels Near New Life Plastic Surgery
Naya Padkar Newspaper Today
Flashscore.com Live Football Scores Livescore
Collier Urgent Care Park Shore
Devotion Showtimes Near The Grand 16 - Pier Park
Craiglist Hollywood
Fwpd Activity Log
Tunica Inmate Roster Release
814-747-6702
Tfn Powerschool
Cult Collectibles - True Crime, Cults, and Murderabilia
San Diego Padres Box Scores
Craigslist Pet Phoenix
Cryptoquote Solver For Today
Hsi Delphi Forum
Kidcheck Login
Ippa 番号
Latest Posts
Article information

Author: Kimberely Baumbach CPA

Last Updated:

Views: 5937

Rating: 4 / 5 (41 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Kimberely Baumbach CPA

Birthday: 1996-01-14

Address: 8381 Boyce Course, Imeldachester, ND 74681

Phone: +3571286597580

Job: Product Banking Analyst

Hobby: Cosplaying, Inline skating, Amateur radio, Baton twirling, Mountaineering, Flying, Archery

Introduction: My name is Kimberely Baumbach CPA, I am a gorgeous, bright, charming, encouraging, zealous, lively, good person who loves writing and wants to share my knowledge and understanding with you.