QPen — PySide 1.2.1 documentation (2024)

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

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

The pen style defines the line type. The brush is used to fill strokes generated with the pen. Use the PySide.QtGui.QBrush class to specify fill styles. The cap style determines the line end caps that can be drawn using PySide.QtGui.QPainter , while the join style describes how joins between two lines are drawn. The pen width can be specified in both integer ( PySide.QtGui.QPen.width() ) and floating point ( PySide.QtGui.QPen.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 transformation set on the painter.

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

For example:

painter = QPainter(self)pen = QPen(Qt.green, 3, Qt.DashDotLine, Qt.RoundCap, Qt.RoundJoin)painter.setPen(pen)

which is equivalent to

painter = QPainter(self)pen = QPen() # creates a default penpen.setStyle(Qt.DashDotLine)pen.setWidth(3)pen.setBrush(Qt.green)pen.setCapStyle(Qt.RoundCap)pen.setJoinStyle(Qt.RoundJoin)painter.setPen(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 PySide.QtGui.QPen provides the PySide.QtGui.QPen.color() and PySide.QtGui.QPen.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.

Join Style

The join style defines how joins between two connected lines can be drawn using PySide.QtGui.QPainter . The join style only apply to wide lines, i.e. when the width is 1 or greater. The Qt.PenJoinStyle enum provides the following styles:

QPen — PySide 1.2.1 documentation (1)QPen — PySide 1.2.1 documentation (2)QPen — PySide 1.2.1 documentation (3)
Qt.BevelJoinQt.MiterJoinQt.RoundJoin

The Qt.BevelJoin style fills the triangular notch between the two lines. The Qt.MiterJoin style extends the lines to meet at an angle. And the Qt.RoundJoin style fills a circular arc between the two lines.

The default is Qt.BevelJoin .

QPen — PySide 1.2.1 documentation (4)

When the Qt.MiterJoin style is applied, it is possible to use the PySide.QtGui.QPen.setMiterLimit() function to specify how far the miter join can extend from the join point. The PySide.QtGui.QPen.miterLimit() is used to reduce artifacts between line joins where the lines are close to parallel.

The PySide.QtGui.QPen.miterLimit() must be specified in units of the pens width, e.g. a miter limit of 5 in width 10 is 50 pixels long. The default miter limit is 2, i.e. twice the pen width in pixels.

QPen — PySide 1.2.1 documentation (5)

** The Path Stroking Demo ****

The Path Stroking demo shows Qt’s built-in dash patterns and shows how custom patterns can be used to extend the range of available patterns.

See also

PySide.QtGui.QPainter PySide.QtGui.QBrush Path Stroking Demo Scribble Example

class PySide.QtGui.QPen
class PySide.QtGui.QPen(arg__1)
class PySide.QtGui.QPen(brush, width[, s=Qt.SolidLine[, c=Qt.SquareCap[, j=Qt.BevelJoin]]])
class PySide.QtGui.QPen(color)
class PySide.QtGui.QPen(pen)
Parameters:
  • widthPySide.QtCore.qreal
  • penPySide.QtGui.QPen
  • jPySide.QtCore.Qt.PenJoinStyle
  • brushPySide.QtGui.QBrush
  • sPySide.QtCore.Qt.PenStyle
  • arg__1PySide.QtCore.Qt.PenStyle
  • cPySide.QtCore.Qt.PenCapStyle
  • colorPySide.QtGui.QColor

Constructs a default black solid line pen with 0 width.

Constructs a solid line pen with 0 width and the given color .

See also

PySide.QtGui.QPen.setBrush() PySide.QtGui.QPen.setColor()

Constructs a pen that is a copy of the given pen .

PySide.QtGui.QPen.brush()
Return type:PySide.QtGui.QBrush

Returns the brush used to fill strokes generated with this pen.

See also

PySide.QtGui.QPen.setBrush()

PySide.QtGui.QPen.capStyle()
Return type:PySide.QtCore.Qt.PenCapStyle

Returns the pen’s cap style.

See also

PySide.QtGui.QPen.setCapStyle() Cap Style

PySide.QtGui.QPen.color()
Return type:PySide.QtGui.QColor

Returns the color of this pen’s brush.

See also

PySide.QtGui.QPen.brush() PySide.QtGui.QPen.setColor()

PySide.QtGui.QPen.dashOffset()
Return type:PySide.QtCore.qreal

Returns the dash offset for the pen.

See also

PySide.QtGui.QPen.setDashOffset()

PySide.QtGui.QPen.dashPattern()
Return type:

Returns the dash pattern of this pen.

See also

PySide.QtGui.QPen.setDashPattern() PySide.QtGui.QPen.style() PySide.QtGui.QPen.isSolid()

PySide.QtGui.QPen.isCosmetic()
Return type:PySide.QtCore.bool

Returns true if the pen is cosmetic; otherwise returns false.

Cosmetic pens are used to draw strokes that have a constant width regardless of any transformations applied to the PySide.QtGui.QPainter they are used with. Drawing a shape with a cosmetic pen ensures that its outline will have the same thickness at different scale factors.

A zero width pen is cosmetic by default; pens with a non-zero width are non-cosmetic.

See also

PySide.QtGui.QPen.setCosmetic() PySide.QtGui.QPen.widthF()

PySide.QtGui.QPen.isSolid()
Return type:PySide.QtCore.bool

Returns true if the pen has a solid fill, otherwise false.

See also

PySide.QtGui.QPen.style() PySide.QtGui.QPen.dashPattern()

PySide.QtGui.QPen.joinStyle()
Return type:PySide.QtCore.Qt.PenJoinStyle

Returns the pen’s join style.

See also

PySide.QtGui.QPen.setJoinStyle() Join Style

PySide.QtGui.QPen.miterLimit()
Return type:PySide.QtCore.qreal

Returns the miter limit of the pen. The miter limit is only relevant when the join style is set to Qt.MiterJoin .

See also

PySide.QtGui.QPen.setMiterLimit() Join Style

PySide.QtGui.QPen.__ne__(p)
Parameters:pPySide.QtGui.QPen
Return type:PySide.QtCore.bool

Returns true if the pen is different from the given pen ; otherwise false. Two pens are different if they have different styles, widths or colors.

See also

PySide.QtGui.QPen.operator==()

PySide.QtGui.QPen.__eq__(p)
Parameters:pPySide.QtGui.QPen
Return type:PySide.QtCore.bool

Returns true if the pen is equal to the given pen ; otherwise false. Two pens are equal if they have equal styles, widths and colors.

See also

PySide.QtGui.QPen.operator!=()

PySide.QtGui.QPen.setBrush(brush)
Parameters:brushPySide.QtGui.QBrush

Sets the brush used to fill strokes generated with this pen to the given brush .

See also

PySide.QtGui.QPen.brush() PySide.QtGui.QPen.setColor()

PySide.QtGui.QPen.setCapStyle(pcs)
Parameters:pcsPySide.QtCore.Qt.PenCapStyle
PySide.QtGui.QPen.setColor(color)
Parameters:colorPySide.QtGui.QColor

Sets the color of this pen’s brush to the given color .

See also

PySide.QtGui.QPen.setBrush() PySide.QtGui.QPen.color()

PySide.QtGui.QPen.setCosmetic(cosmetic)
Parameters:cosmeticPySide.QtCore.bool

Sets this pen to cosmetic or non-cosmetic, depending on the value of cosmetic .

See also

PySide.QtGui.QPen.isCosmetic()

PySide.QtGui.QPen.setDashOffset(doffset)
Parameters:doffsetPySide.QtCore.qreal

Sets the dash offset (the starting point on the dash pattern) for this pen to the offset specified. The offset is measured in terms of the units used to specify the dash pattern.

QPen — PySide 1.2.1 documentation (6)

For example, a pattern where each stroke is four units long, followed by a gap of two units, will begin with the stroke when drawn as a line.

However, if the dash offset is set to 4.0, any line drawn will begin with the gap. Values of the offset up to 4.0 will cause part of the stroke to be drawn first, and values of the offset between 4.0 and 6.0 will cause the line to begin with part of the gap.

Note

This implicitly converts the style of the pen to Qt.CustomDashLine .

See also

PySide.QtGui.QPen.dashOffset()

PySide.QtGui.QPen.setDashPattern(pattern)
Parameters:pattern
PySide.QtGui.QPen.setJoinStyle(pcs)
Parameters:pcsPySide.QtCore.Qt.PenJoinStyle
PySide.QtGui.QPen.setMiterLimit(limit)
Parameters:limitPySide.QtCore.qreal

Sets the miter limit of this pen to the given limit .

QPen — PySide 1.2.1 documentation (7)

The miter limit describes how far a miter join can extend from the join point. This is used to reduce artifacts between line joins where the lines are close to parallel.

This value does only have effect when the pen style is set to Qt.MiterJoin . The value is specified in units of the pen’s width, e.g. a miter limit of 5 in width 10 is 50 pixels long. The default miter limit is 2, i.e. twice the pen width in pixels.

See also

PySide.QtGui.QPen.miterLimit() PySide.QtGui.QPen.setJoinStyle() Join Style

PySide.QtGui.QPen.setStyle(arg__1)
Parameters:arg__1PySide.QtCore.Qt.PenStyle
PySide.QtGui.QPen.setWidth(width)
Parameters:widthPySide.QtCore.int

Sets the pen width to the given width in pixels with integer 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 transformation set on the painter.

Setting a pen width with a negative value is not supported.

See also

PySide.QtGui.QPen.setWidthF() PySide.QtGui.QPen.width()

PySide.QtGui.QPen.setWidthF(width)
Parameters:widthPySide.QtCore.qreal

Sets the pen width to the given width in pixels with floating point 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 transformation on the painter.

Setting a pen width with a negative value is not supported.

See also

PySide.QtGui.QPen.setWidth() PySide.QtGui.QPen.widthF()

PySide.QtGui.QPen.style()
Return type:PySide.QtCore.Qt.PenStyle

Returns the pen style.

See also

PySide.QtGui.QPen.setStyle() Pen Style

PySide.QtGui.QPen.swap(other)
Parameters:otherPySide.QtGui.QPen

Swaps pen other with this pen. This operation is very fast and never fails.

PySide.QtGui.QPen.width()
Return type:PySide.QtCore.int

Returns the pen width with integer precision.

See also

PySide.QtGui.QPen.setWidth() PySide.QtGui.QPen.widthF()

PySide.QtGui.QPen.widthF()
Return type:PySide.QtCore.qreal

Returns the pen width with floating point precision.

See also

PySide.QtGui.QPen.setWidthF() PySide.QtGui.QPen.width()

QPen — PySide 1.2.1 documentation (2024)

References

Top Articles
Keto Cheesecake Recipe (Low Carb Sugar-Free Cheesecake) | Wholesome Yum
9 High Protein Low Carb Recipes For Faster Fat Loss | HIIT WEEKLY
St Thomas Usvi Craigslist
No Limit Telegram Channel
Chambersburg star athlete JJ Kelly makes his college decision, and he’s going DI
Cad Calls Meriden Ct
9192464227
Kristine Leahy Spouse
Best Private Elementary Schools In Virginia
The Many Faces of the Craigslist Killer
Lqse-2Hdc-D
4Chan Louisville
De Leerling Watch Online
Slag bij Plataeae tussen de Grieken en de Perzen
Belle Delphine Boobs
How To Cut Eelgrass Grounded
50 Shades Darker Movie 123Movies
Wausau Obits Legacy
Ukc Message Board
Ppm Claims Amynta
Baja Boats For Sale On Craigslist
yuba-sutter apartments / housing for rent - craigslist
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Sunset Time November 5 2022
15 Primewire Alternatives for Viewing Free Streams (2024)
Renfield Showtimes Near Paragon Theaters - Coral Square
Black Lion Backpack And Glider Voucher
Kaliii - Area Codes Lyrics
How rich were the McCallisters in 'Home Alone'? Family's income unveiled
Ancestors The Humankind Odyssey Wikia
Wbli Playlist
Weekly Math Review Q4 3
Lake Dunson Robertson Funeral Home Lagrange Georgia Obituary
Craigslist Red Wing Mn
Pepsi Collaboration
Temu Y2K
Worcester County Circuit Court
Lake Andes Buy Sell Trade
Lake Kingdom Moon 31
O'reilly's Palmyra Missouri
Cnp Tx Venmo
Acts 16 Nkjv
Joey Gentile Lpsg
Shipping Container Storage Containers 40'HCs - general for sale - by dealer - craigslist
Mynord
Professors Helpers Abbreviation
Mytmoclaim Tracking
Sitka Alaska Craigslist
Craigslist Sarasota Free Stuff
Wvu Workday
Att Corporate Store Location
One Facing Life Maybe Crossword
Latest Posts
Article information

Author: Greg O'Connell

Last Updated:

Views: 5939

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Greg O'Connell

Birthday: 1992-01-10

Address: Suite 517 2436 Jefferey Pass, Shanitaside, UT 27519

Phone: +2614651609714

Job: Education Developer

Hobby: Cooking, Gambling, Pottery, Shooting, Baseball, Singing, Snowboarding

Introduction: My name is Greg O'Connell, I am a delightful, colorful, talented, kind, lively, modern, tender person who loves writing and wants to share my knowledge and understanding with you.