The QBrush class defines the fill pattern of shapes drawn using the QPainter. (details) (complete member list)
#include <qbrush.h>
A brush has a style and a color. One of the brush styles is a custom pattern, which is defined by a QBitmap.
The brush style defines the fill pattern. The default brush style is NoBrush
(depends on how you construct a brush). This style tells the
painter to not fill shapes. The standard style for filling is called SolidPattern.
The brush color defines the color of the fill pattern. The QColor documentation contains a list of standard colors.
Use the QPen class for specifying line/outline styles.
Example of how to use a brush:
QPainter painter;
QBrush brush( yellow ); // yellow solid pattern
QPen pen( red ); // red solid line, 0 width
painter.begin( &anyPaintDevice ); // paint widget, pixmap etc.
painter.setBrush( brush ); // sets the yellow brush
painter.setPen( pen ); // sets the red pen
painter.drawRect( 40,30, 200,100 ); // draw 200x100 rect at (40,30)
painter.brush().setStyle( NoBrush ); // do not fill
painter.drawrect( 10,10, 30,20 ); // draw rectangle outline
painter.end(); // painting done
The setStyle() function has a list of brush styles.
Constructs a default black brush with the style NoBrush
(will not fill
shapes).
Constructs a black brush with the specified style.
Constructs a brush with a specified color and style.
Constructs a brush with a specified color and a custom pattern.
Constructs a brush which is a shallow copy of b.
Destroys the brush.
Returns a pointer to the custom brush pattern.
A null pointer is returned if no custom brush pattern has been set.
See also: setBitmap().
Returns the brush color.
See also: setColor().
Returns a deep copy of the brush.
Detaches from shared brush data to makes sure that this brush is the only one referring the data.
If multiple brushes share common data, this pen dereferences the data and gets a copy of the data. Nothing will be done if there is just a single reference.
Returns TRUE if the brush is different from b, or FALSE if the brushes are equal.
Two brushes are different if they have different styles, colors or bitmaps.
Assigns a shallow copy of b to the brush and returns a reference to this brush.
Returns TRUE if the brush is equal to b, or FALSE if the brushes are different.
Two brushes are equal if they have equal styles, colors and bitmaps.
Returns the brush style.
See also: setStyle().
Writes a brush to the stream.
Reads a brush from the stream.
This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.
It was generated from the following files: