Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QBrush Class Reference

List of all members.

Detailed Description

The QBrush class defines the fill pattern of shapes drawn by QPainter.

A brush has a style, a color, a gradient and a texture.

The brush style() defines the fill pattern using the Qt::BrushStyle enum. The default brush style is Qt::NoBrush (depending on how you construct a brush). This style tells the painter to not fill shapes. The standard style for filling is Qt::SolidPattern. The style can be set when the brush is created using the appropriate constructor, and in addition the setStyle() function provides means for altering the style once the brush is constructed.

Brush Styles

The brush color() defines the color of the fill pattern. The color can either be one of Qt's predefined colors, Qt::GlobalColor, or any other custom QColor. The currently set color can be retrieved and altered using the color() and setColor() functions, respectively.

The gradient() defines the gradient fill used when the current style is either Qt::LinearGradientPattern, Qt::RadialGradientPattern or Qt::ConicalGradientPattern. Gradient brushes are created by giving a QGradient as a constructor argument when creating the QBrush. Qt provides three different gradients: QLinearGradient, QConicalGradient, and QRadialGradient

doc/src/snippets/brush/gradientcreationsnippet.cpp 0

The texture() defines the pixmap used when the current style is Qt::TexturePattern. You can create a brush with a texture by providing the pixmap when the brush is created or by using setTexture().

Note that applying setTexture() makes style() == Qt::TexturePattern, regardless of previous style settings. Also, calling setColor() will not make a difference if the style is a gradient. The same is the case if the style is Qt::TexturePattern style unless the current texture is a QBitmap.

The isOpaque() function returns true if the brush is fully opaque otherwise false. A brush is considered opaque if:

The alpha component of the color() is 255. Its texture() does not have an alpha channel and is not a QBitmap. The colors in the gradient() all have an alpha component that is 255.

100% brush-outline.png Outlines

To specify the style and color of lines and outlines, use the QPainter's {QPen}{pen} combined with Qt::PenStyle and Qt::GlobalColor:

doc/src/snippets/code/src_gui_painting_qbrush.cpp 0

Note that, by default, QPainter renders the outline (using the currently set pen) when drawing shapes. Use {Qt::NoPen}{painter.setPen(Qt::NoPen)} to disable this behavior.

For more information about painting in general, see {The Paint System} documentation.

See also:
Qt::BrushStyle, QPainter, QColor

Definition at line 67 of file qbrush.h.

Public Types

typedef QBrushData * DataPtr

Public Member Functions

const QColorcolor () const
DataPtrdata_ptr ()
const QGradientgradient () const
bool isDetached () const
bool isOpaque () const
const QMatrixmatrix () const
 operator QVariant () const
bool operator!= (const QBrush &b) const
QBrushoperator= (const QBrush &brush)
bool operator== (const QBrush &b) const
 QBrush (const QGradient &gradient)
 QBrush (const QBrush &brush)
 QBrush (const QImage &image)
 QBrush (const QPixmap &pixmap)
 QBrush (Qt::GlobalColor color, const QPixmap &pixmap)
 QBrush (const QColor &color, const QPixmap &pixmap)
 QBrush (Qt::GlobalColor color, Qt::BrushStyle bs=Qt::SolidPattern)
 QBrush (const QColor &color, Qt::BrushStyle bs=Qt::SolidPattern)
 QBrush (Qt::BrushStyle bs)
 QBrush ()
void setColor (Qt::GlobalColor color)
void setColor (const QColor &color)
void setMatrix (const QMatrix &mat)
void setStyle (Qt::BrushStyle)
void setTexture (const QPixmap &pixmap)
void setTextureImage (const QImage &image)
void setTransform (const QTransform &)
Qt::BrushStyle style () const
QPixmap texture () const
QImage textureImage () const
QTransform transform () const
 ~QBrush ()

Private Member Functions

void cleanUp (QBrushData *x)
void detach (Qt::BrushStyle newStyle)
void init (const QColor &color, Qt::BrushStyle bs)

Private Attributes

QBrushData * d


bool qHasPixmapTexture (const QBrush &brush)
class QPainter
class QRasterPaintEngine
class QRasterPaintEnginePrivate
struct QSpanData

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QBrush &brush)
QDataStreamoperator>> (QDataStream &stream, QBrush &brush)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index