QBrush
Section: Misc. Reference Manual Pages (3qt)
Updated: 2 February 2007
Index
Return to Main Contents
NAME
QBrush - Defines the fill pattern of shapes drawn by a QPainter
SYNOPSIS
#include <qbrush.h>
Inherits Qt.
Public Members
QBrush ()
QBrush ( BrushStyle style )
QBrush ( const QColor & color, BrushStyle style = SolidPattern )
QBrush ( const QColor & color, const QPixmap & pixmap )
QBrush ( const QBrush & b )
~QBrush ()
QBrush & operator= ( const QBrush & b )
BrushStyle style () const
void setStyle ( BrushStyle s )
const QColor & color () const
void setColor ( const QColor & c )
QPixmap * pixmap () const
void setPixmap ( const QPixmap & pixmap )
bool operator== ( const QBrush & b ) const
bool operator!= ( const QBrush & b ) const
RELATED FUNCTION DOCUMENTATION
QDataStream & operator<< ( QDataStream & s, const QBrush & b )
QDataStream & operator>> ( QDataStream & s, QBrush & b )
DESCRIPTION
The QBrush class defines the fill pattern of shapes drawn by a QPainter.
A brush has a style and a color. One of the brush styles is a custom pattern, which is defined by a QPixmap.
The brush style defines the fill pattern. The default brush style is NoBrush (depending on how you construct a brush). This style tells the painter to not fill shapes. The standard style for filling is SolidPattern.
The brush color defines the color of the fill pattern. The QColor documentation lists the predefined colors.
Use the QPen class for specifying line/outline styles.
Example:
QPainter painter;
QBrush brush( yellow ); // yellow solid pattern
painter.begin( &anyPaintDevice ); // paint something
painter.setBrush( brush ); // set the yellow brush
painter.setPen( NoPen ); // do not draw outline
painter.drawRect( 40,30, 200,100 ); // draw filled rectangle
painter.setBrush( NoBrush ); // do not fill
painter.setPen( black ); // set black pen, 0 pixel width
painter.drawRect( 10,10, 30,20 ); // draw rectangle outline
painter.end(); // painting done
See the setStyle() function for a complete list of brush styles.
<center>
[Image Omitted]
</center>
See also QPainter, QPainter::setBrush(), QPainter::setBrushOrigin(), Graphics Classes, Image Processing Classes, and Implicitly and Explicitly Shared Classes.
MEMBER FUNCTION DOCUMENTATION
QBrush::QBrush ()
Constructs a default black brush with the style NoBrush (will not fill shapes).
QBrush::QBrush ( BrushStyle style )
Constructs a black brush with the style style.
See also setStyle().
QBrush::QBrush ( const QColor & color, BrushStyle style = SolidPattern )
Constructs a brush with the color color and the style style.
See also setColor() and setStyle().
QBrush::QBrush ( const QColor & color, const QPixmap & pixmap )
Constructs a brush with the color color and a custom pattern stored in