Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions | ![]() |
The QBrush class defines the fill pattern of shapes drawn by a QPainter. More...
#include <QBrush>
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 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 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(Qt::NoPen); // do not draw outline painter.drawRect(40,30, 200,100); // draw filled rectangle painter.setBrush(Qt::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 QPainter, QPainter::setBrush(), and QPainter::setBrushOrigin().
Constructs a default black brush with the style Qt::NoBrush (will not fill shapes).
Constructs a black brush with the style style.
See also setStyle().
Constructs a brush with the color color and the style style.
See also setColor() and setStyle().
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 QPixmap::depth() == 1.
Pixmap brushes are currently not supported when printing on X11.
See also setColor() and setPixmap().
Constructs a brush with a black color and a pixmap set to pixmap.
Constructs a brush that is a shallow copy of b.
Creates a linear gradient brush. The brush will interpolate between the color col1 in the point p1 to the color col2 in the point p2. The areas outside the interpolation area is filled with the color for that corresponding side.
Constructs a brush with the color color and the style style.
See also setColor() and setStyle().
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 QPixmap::depth() == 1.
Pixmap brushes are currently not supported when printing on X11.
See also setColor() and setPixmap().
Destroys the brush.
Returns the brush color.
See also setColor().
Returns the gradient's secondary color.
See also gradientStart() and gradientStop().
Returns the gradient's starting color.
See also gradientStop() and gradientColor().
Returns the gradient's ending color.
See also gradientStart() and gradientColor().
Returns a pointer to the custom brush pattern, or 0 if no custom brush pattern has been set.
See also setPixmap().
Sets the brush color to c.
See also color() and setStyle().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the brush pixmap to pixmap. The style is set to Qt::CustomPattern.
The current brush color will only have an effect for monochrome pixmaps, i.e. for QPixmap::depth() == 1.
Pixmap brushes are currently not supported when printing on X11.
See also pixmap() and color().
Sets the brush style to s.
The brush styles are:
Pattern | Meaning |
---|---|
Qt::NoBrush | will not fill shapes (default). |
Qt::SolidPattern | solid (100%) fill pattern. |
Qt::Dense1Pattern | 94% fill pattern. |
Qt::Dense2Pattern | 88% fill pattern. |
Qt::Dense3Pattern | 63% fill pattern. |
Qt::Dense4Pattern | 50% fill pattern. |
Qt::Dense5Pattern | 37% fill pattern. |
Qt::Dense6Pattern | 12% fill pattern. |
Qt::Dense7Pattern | 6% fill pattern. |
Qt::HorPattern | horizontal lines pattern. |
Qt::VerPattern | vertical lines pattern. |
Qt::CrossPattern | crossing lines pattern. |
Qt::BDiagPattern | diagonal lines (directed /) pattern. |
Qt::FDiagPattern | diagonal lines (directed ) pattern. |
Qt::DiagCrossPattern | diagonal crossing lines pattern. |
Qt::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().
Returns the brush style.
See also setStyle().
Returns the brush's color.
Returns the brush's pixmap.
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==().
Assigns b to this brush and returns a reference to this brush.
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!=().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Writes the brush b to the stream s and returns a reference to the stream.
See also Format of the QDataStream operators.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Reads the brush b from the stream s and returns a reference to the stream.
See also Format of the QDataStream operators.
Copyright © 2004 Trolltech. | Trademarks | Qt 4.0.0-tp2 |