Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtGui.QBrush Class Reference

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

Inheritance diagram for QtGui.QBrush:
Collaboration diagram for QtGui.QBrush:

Public Member Functions

override bool Equals (object o)
 
override int GetHashCode ()
 
 QBrush ()
 
 
 QBrush (QPixmap pixmap)
 
 
 QBrush (QImage image)
 
 
 QBrush (QBrush brush)
 
 
 QBrush (QGradient gradient)
 
 
 QBrush (QColor color, QPixmap pixmap)
 
 
 QBrush (QColor color, Qt.BrushStyle bs=Qt.BrushStyle.SolidPattern)
 
 
 QBrush (Qt.BrushStyle bs)
 
 
 QBrush (Qt.GlobalColor color, QPixmap pixmap)
 
 
 QBrush (Qt.GlobalColor color, Qt.BrushStyle bs=Qt.BrushStyle.SolidPattern)
 
 
virtual void CreateProxy ()
 
new QGradient Gradient ()
 
 
new bool IsDetached ()
 
new bool IsOpaque ()
 
 
new void SetColor (Qt.GlobalColor color)
 
 
new void Swap (QBrush other)
 
 
new void Dispose ()
 

Static Public Member Functions

static bool operator!= (QBrush arg1, QBrush arg2)
 
 
static bool operator== (QBrush arg1, QBrush arg2)
 
 

Protected Member Functions

 QBrush (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

new QColor Color [get, set]
 
 
new QMatrix Matrix [get, set]
 
 
new Qt.BrushStyle Style [get, set]
 
 
new QPixmap Texture [get, set]
 
 
new QImage TextureImage [get, set]
 
 
new QTransform Transform [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 

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.

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 - all of which inherit QGradient.

QRadialGradient gradient(50, 50, 50, 50, 50);

gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1));

gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));

QBrush brush(gradient);

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.

To specify the style and color of lines and outlines, use the QPainter's pen combined with Qt::PenStyle and Qt::GlobalColor: QPainter painter(this);

painter.setBrush(Qt::cyan);

painter.setPen(Qt::darkCyan);

painter.drawRect(0, 0, 100,100);

painter.setBrush(Qt::NoBrush);

painter.setPen(Qt::darkGreen);

painter.drawRect(40, 40, 100, 100);

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

For more information about painting in general, see the Paint System.

See also Qt::BrushStyle, QPainter, and QColor.

Constructor & Destructor Documentation

QtGui.QBrush.QBrush ( System.Type  dummy)
protected
QtGui.QBrush.QBrush ( )

Constructs a default black brush with the style Qt::NoBrush (i.e. this brush will not fill shapes).

QtGui.QBrush.QBrush ( QPixmap  pixmap)

Constructs a brush with a black color and a texture set to the given pixmap. The style is set to Qt::TexturePattern.

See also setTexture().

QtGui.QBrush.QBrush ( QImage  image)

Constructs a brush with a black color and a texture set to the given image. The style is set to Qt::TexturePattern.

See also setTextureImage().

QtGui.QBrush.QBrush ( QBrush  brush)

Constructs a copy of other.

QtGui.QBrush.QBrush ( QGradient  gradient)

Constructs a brush based on the given gradient.

The brush style is set to the corresponding gradient style (either Qt::LinearGradientPattern, Qt::RadialGradientPattern or Qt::ConicalGradientPattern).

QtGui.QBrush.QBrush ( QColor  color,
QPixmap  pixmap 
)

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

The style is set to Qt::TexturePattern. The color will only have an effect for QBitmaps.

See also setColor() and setPixmap().

QtGui.QBrush.QBrush ( QColor  color,
Qt.BrushStyle  bs = Qt.BrushStyle.SolidPattern 
)

Constructs a default black brush with the style Qt::NoBrush (i.e. this brush will not fill shapes).

QtGui.QBrush.QBrush ( Qt.BrushStyle  bs)

Constructs a black brush with the given style.

See also setStyle().

QtGui.QBrush.QBrush ( Qt.GlobalColor  color,
QPixmap  pixmap 
)

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

The style is set to Qt::TexturePattern. The color will only have an effect for QBitmaps.

See also setColor() and setPixmap().

QtGui.QBrush.QBrush ( Qt.GlobalColor  color,
Qt.BrushStyle  bs = Qt.BrushStyle.SolidPattern 
)

Constructs a default black brush with the style Qt::NoBrush (i.e. this brush will not fill shapes).

Member Function Documentation

virtual void QtGui.QBrush.CreateProxy ( )
virtual
new void QtGui.QBrush.Dispose ( )
override bool QtGui.QBrush.Equals ( object  o)
override int QtGui.QBrush.GetHashCode ( )
new QGradient QtGui.QBrush.Gradient ( )

Returns the gradient describing this brush.

new bool QtGui.QBrush.IsDetached ( )
new bool QtGui.QBrush.IsOpaque ( )

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.

It is an extended radial gradient.

static bool QtGui.QBrush.operator!= ( QBrush  arg1,
QBrush  arg2 
)
static

Returns true if the brush is different from the given brush; otherwise returns false.

Two brushes are different if they have different styles, colors or transforms or different pixmaps or gradients depending on the style.

See also operator==().

static bool QtGui.QBrush.operator== ( QBrush  arg1,
QBrush  arg2 
)
static

Returns true if the brush is equal to the given brush; otherwise returns false.

Two brushes are equal if they have equal styles, colors and transforms and equal pixmaps or gradients depending on the style.

See also operator!=().

new void QtGui.QBrush.SetColor ( Qt.GlobalColor  color)

This is an overloaded function.

Sets the brush color to the given color.

new void QtGui.QBrush.Swap ( QBrush  other)

Swaps brush other with this brush. This operation is very fast and never fails.

This function was introduced in Qt 4.8.

Member Data Documentation

SmokeInvocation QtGui.QBrush.interceptor
protected

Property Documentation

new QColor QtGui.QBrush.Color
getset

Returns the brush color.

Sets the brush color to the given color.

Note that 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.

new QMatrix QtGui.QBrush.Matrix
getset

Returns the current transformation matrix for the brush.

This function was introduced in Qt 4.2.

Sets matrix as an explicit transformation matrix on the current brush. The brush transformation matrix is merged with QPainter transformation matrix to produce the final result.

This function was introduced in Qt 4.2.

virtual System.IntPtr QtGui.QBrush.SmokeObject
getset
new Qt.BrushStyle QtGui.QBrush.Style
getset

Returns the brush style.

Sets the brush style to style.

new QPixmap QtGui.QBrush.Texture
getset

Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set.

Sets the brush pixmap to pixmap. The style is set to Qt::TexturePattern.

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

new QImage QtGui.QBrush.TextureImage
getset

Returns the custom brush pattern, or a null image if no custom brush pattern has been set.

If the texture was set as a QPixmap it will be converted to a QImage.

This function was introduced in Qt 4.2.

Sets the brush image to image. The style is set to Qt::TexturePattern.

Note the current brush color will not have any affect on monochrome images, as opposed to calling setTexture() with a QBitmap. If you want to change the color of monochrome image brushes, either convert the image to QBitmap with QBitmap::fromImage() and set the resulting QBitmap as a texture, or change the entries in the color table for the image.

This function was introduced in Qt 4.2.

new QTransform QtGui.QBrush.Transform
getset

Returns the current transformation matrix for the brush.

This function was introduced in Qt 4.3.

Sets matrix as an explicit transformation matrix on the current brush. The brush transformation matrix is merged with QPainter transformation matrix to produce the final result.

This function was introduced in Qt 4.3.