QPen Class ReferenceThe QPen class defines how a QPainter should draw lines and outlines of shapes. More... #include <qpen.h> Inherits Qt. Public Members
Related Functions
Detailed DescriptionThe QPen class defines how a QPainter should draw lines and outlines of 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 to not draw lines or outlines. When drawing 1 pixel wide diagonal lines you can either use a very fast algorithm (specified by a line width of 0, which is the default), or a slower but more accurate algorithm (specified by a line width of 1). For horizontal and vertical lines a line width of 0 is the same as a line width of 1. The cap and join style have no effect on 0-width lines. The pen color defines the color of lines and text. The default line color is black. The QColor documentation lists predefined colors. The cap style defines how the end points of lines are drawn. The join style defines how the joins between two lines are drawn when multiple connected lines are drawn (QPainter::drawPolyline() etc.). The cap and join styles only apply to wide lines, i.e. when the 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 pen styles. 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 or not. QPainter will try to make sure that the end point is drawn for 0-width pens, but this cannot be absolutely guaranteed because the underlying drawing engine is free to use any (typically accelerated) algorithm for drawing 0-width lines. On all tested systems, however, the end point of at least all non-diagonal lines are drawn. A pen's color(), width(), style(), capStyle() and joinStyle() can be set in the constructor or later with setColor(), setWidth(), setStyle(), setCapStyle() and setJoinStyle(). Pens may also be compared and streamed.
See also QPainter, QPainter::setPen(), Graphics Classes, Image Processing Classes, and Implicitly and Explicitly Shared Classes. Member Function Documentation
Constructs a default black solid line pen with 0 width, which
renders lines 1 pixel wide (fast diagonals).
|
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Quarterly au hasardXQuery et la météoQt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.
CommunautéRessources
Liens utilesContact
Qt dans le magazine |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 3.2 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com