Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# TQBrush Class Reference

The TQBrush class defines the fill pattern of shapes drawn by a TQPainter. More...

`#include <ntqbrush.h>`

Inherits TQt.

List of all member functions.

## Public Members

- TQBrush ()
- TQBrush ( BrushStyle style )
- TQBrush ( const TQColor & color, BrushStyle style = SolidPattern )
- TQBrush ( const TQColor & color, const TQPixmap & pixmap )
- TQBrush ( const TQBrush & b )
- ~TQBrush ()
- TQBrush & operator= ( const TQBrush & b )
- BrushStyle style () const
- void setStyle ( BrushStyle s )
- const TQColor & color () const
- void setColor ( const TQColor & c )
- TQPixmap * pixmap () const
- void setPixmap ( const TQPixmap & pixmap )
- bool operator== ( const TQBrush & b ) const
- bool operator!= ( const TQBrush & b ) const

## Related Functions

- TQDataStream & operator<< ( TQDataStream & s, const TQBrush & b )
- TQDataStream & operator>> ( TQDataStream & s, TQBrush & b )

## Detailed Description

The TQBrush class defines the fill pattern of shapes drawn by a TQPainter.

A brush has a style and a color. One of the brush styles is a custom pattern, which is defined by a TQPixmap.

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 TQColor documentation lists the predefined colors.

Use the TQPen class for specifying line/outline styles.

Example:

            TQPainter painter;
            TQBrush   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.

See also TQPainter, TQPainter::setBrush(), TQPainter::setBrushOrigin(), Graphics Classes, Image Processing Classes, and Implicitly and Explicitly Shared Classes.

## Member Function Documentation

### TQBrush::TQBrush ()

Constructs a default black brush with the style NoBrush (will not fill shapes).

### TQBrush::TQBrush ( BrushStyle style )

Constructs a black brush with the style style.

See also setStyle().

### TQBrush::TQBrush ( const TQColor & color, BrushStyle style = SolidPattern )

Constructs a brush with the color color and the style style.

See also setColor() and setStyle().

### TQBrush::TQBrush ( const TQColor & color, const TQPixmap & pixmap )

Constructs a brush with the color color and a custom pattern stored in pixmap.

The color will only have an effect for monochrome pixmaps, i.e. for TQPixmap::depth() == 1.

Pixmap brushes are currently not supported when printing on X11.

See also setColor() and setPixmap().

### TQBrush::TQBrush ( const TQBrush & b )

Constructs a brush that is a shallow copy of b.

### TQBrush::~TQBrush ()

Destroys the brush.

### const TQColor & TQBrush::color () const

Returns the brush color.

See also setColor().

### bool TQBrush::operator!= ( const TQBrush & b ) const

Returns TRUE if the brush is different from b; otherwise returns FALSE.

Two brushes are different if they have different styles, colors or pixmaps.

See also operator==().

### TQBrush & TQBrush::operator= ( const TQBrush & b )

Assigns b to this brush and returns a reference to this brush.

### bool TQBrush::operator== ( const TQBrush & b ) const

Returns TRUE if the brush is equal to b; otherwise returns FALSE.

Two brushes are equal if they have equal styles, colors and pixmaps.

See also operator!=().

### TQPixmap * TQBrush::pixmap () const

Returns a pointer to the custom brush pattern, or 0 if no custom brush pattern has been set.

See also setPixmap().

Example: richtext/richtext.cpp.

### void TQBrush::setColor ( const TQColor & c )

Sets the brush color to c.

See also color() and setStyle().

Example: picture/picture.cpp.

### void TQBrush::setPixmap ( const TQPixmap & pixmap )

Sets the brush pixmap to pixmap. The style is set to CustomPattern.

The current brush color will only have an effect for monochrome pixmaps, i.e. for TQPixmap::depth() == 1.

Pixmap brushes are currently not supported when printing on X11.

See also pixmap() and color().

Example: richtext/richtext.cpp.

### void TQBrush::setStyle ( BrushStyle s )

Sets the brush style to s.

The brush styles are:

Pattern | Meaning
--- | ---
NoBrush | will not fill shapes (default).
SolidPattern | solid (100%) fill pattern.
Dense1Pattern | 94% fill pattern.
Dense2Pattern | 88% fill pattern.
Dense3Pattern | 63% fill pattern.
Dense4Pattern | 50% fill pattern.
Dense5Pattern | 37% fill pattern.
Dense6Pattern | 12% fill pattern.
Dense7Pattern | 6% fill pattern.
HorPattern | horizontal lines pattern.
VerPattern | vertical lines pattern.
CrossPattern | crossing lines pattern.
BDiagPattern | diagonal lines (directed /) pattern.
FDiagPattern | diagonal lines (directed \) pattern.
DiagCrossPattern | diagonal crossing lines pattern.
CustomPattern | set when a pixmap pattern is being used.

On Windows, dense and custom patterns cannot be transparent.

See the Detailed Description for a picture of all the styles.

See also style().

### BrushStyle TQBrush::style () const

Returns the brush style.

See also setStyle().

## Related Functions

### TQDataStream & operator<< ( TQDataStream & s, const TQBrush & b )

Writes the brush b to the stream s and returns a reference to the stream.

See also Format of the TQDataStream operators.

### TQDataStream & operator>> ( TQDataStream & s, TQBrush & b )

Reads the brush b from the stream s and returns a reference to the stream.

See also Format of the TQDataStream operators.

This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.