[QtGui module]
该QBrush类定义形状由绘制的填充图案QPainter。More…
Methods
__init__ (self)
__init__ (self, Qt.BrushStyle bs)
__init__ (self, QColor color, Qt.BrushStyle style = Qt.SolidPattern)
__init__ (self, Qt.GlobalColor color, Qt.BrushStyle style = Qt.SolidPattern)
__init__ (self, QColor color, QPixmap pixmap)
__init__ (self, Qt.GlobalColor color, QPixmap pixmap)
__init__ (self, QPixmap pixmap)
__init__ (self, QImage image)
__init__ (self, QGradient gradient)
__init__ (self, QBrush brush)
__init__ (self, QVariant variant)
QColor color (self)
QGradient gradient (self)
bool isOpaque (self)
QMatrix matrix (self)
setColor (self, QColor color)
setColor (self, Qt.GlobalColor acolor)
setMatrix (self, QMatrix mat)
setStyle (self, Qt.BrushStyle)
setTexture (self, QPixmap pixmap)
setTextureImage (self, QImage image)
setTransform (self, QTransform)
Qt.BrushStyle style (self)
swap (self, QBrush other)
QPixmap texture (self)
QImage textureImage (self)
QTransform transform (self)
Special Methods
bool __eq__ (self, QBrush b)
bool __ne__ (self, QBrush b)
Detailed Description
A QColor或QGradient可用于每当一个QBrush预计。
该QBrush类定义形状由绘制的填充图案QPainter。
刷子有一种风格,一种颜色,渐变和纹理。
刷style( )定义了使用填充图案Qt.BrushStyle枚举。默认的画笔风格Qt.NoBrush(这取决于你如何构建一个刷) 。这种风格告诉画家不填充形状。标准样式的填充物是Qt.SolidPattern。该风格时,可以使用适当的构造函数创建的画笔进行设置,另外的setStyle()函数,提供了用于改变样式一旦刷子构造。
刷color()定义的填充图案的颜色。颜色可以是Qt的预定义的颜色之一,Qt.GlobalColor或任何其它定制QColor。当前设置的颜色可以检索和使用改变了color()和setColor( )函数,分别为。
该gradient( )定义所使用的渐变填充时,当前样式可以是Qt.LinearGradientPattern,Qt.RadialGradientPattern or Qt.ConicalGradientPattern。渐变画刷是由给人一种创造QGradient作为创建QBrush当一个构造函数的参数。 Qt提供了三种不同的梯度:QLinearGradient,QConicalGradient和QRadialGradient - 所有这些都继承QGradient。
[QRadialGradient](docs_qradialgradient.html) gradient(50, 50, 50, 50, 50);
gradient.setColorAt(0, [QColor](docs_qcolor.html).fromRgbF(0, 1, 0, 1));
gradient.setColorAt(1, [QColor](docs_qcolor.html).fromRgbF(0, 0, 0, 0));
QBrush brush(gradient);
该texture( )定义了像素图使用时的电流风格Qt.TexturePattern。您可以通过创建刷的时候提供的像素映射或通过使用创建带有纹理笔刷setTexture( ) 。
请注意,申请setTexture( )使style()==Qt.TexturePattern,不管先前的样式设置。此外,调用setColor( )将不会有所作为,如果风格是一个梯度。同样的情况下,如果风格Qt.TexturePattern风格,除非当前的纹理是QBitmap。
该isOpaque如果刷的是完全不透明的,否则为False ( )函数返回True。刷子被认为是不透明的,如果:
- 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](docs_qpainter.html) painter(this);
painter.setBrush([Qt](docs_qt.html).cyan);
painter.setPen([Qt](docs_qt.html).darkCyan);
painter.drawRect(0, 0, 100,100);
painter.setBrush([Qt](docs_qt.html).NoBrush);
painter.setPen([Qt](docs_qt.html).darkGreen);
painter.drawRect(40, 40, 100, 100);
需要注意的是,默认情况下,QPainter绘制形状时呈现的轮廓(使用当前设置的画笔) 。使用[painter.setPen(Qt.NoPen)](docs_qt.html#PenStyle-enum)
要禁用此行为。 |
有关油画一般的详细信息,请参阅Paint System。
Method Documentation
QBrush.__init__ (self)
构造一个默认的黑色画笔的风格Qt.NoBrush(即此刷不会填充形状) 。
QBrush.__init__ (self, Qt.BrushStyle bs)
构造一个黑色画笔给定的style。
See also setStyle( ) 。
QBrush.__init__ (self, QColor color, Qt.BrushStyle style = Qt.SolidPattern)
构造一个刷用给定的color和style。
See also setColor()和setStyle( ) 。
QBrush.__init__ (self, Qt.GlobalColor color, Qt.BrushStyle style = Qt.SolidPattern)
构造一个刷用给定的color和style。
See also setColor()和setStyle( ) 。
QBrush.__init__ (self, QColor color, QPixmap pixmap)
构造一个刷用给定的color和存储在所述定制模式pixmap。
该样式设置为Qt.TexturePattern。颜色将只对QBitmaps的效果。
See also setColor()和setPixmap( ) 。
QBrush.__init__ (self, Qt.GlobalColor color, QPixmap pixmap)
构造一个刷用给定的color和存储在所述定制模式pixmap。
该样式设置为Qt.TexturePattern。颜色将只对QBitmaps的效果。
See also setColor()和setPixmap( ) 。
QBrush.__init__ (self, QPixmap pixmap)
构造一个刷黑颜色和一组纹理定pixmap。该样式设置为Qt.TexturePattern。
See also setTexture( ) 。
QBrush.__init__ (self, QImage image)
构造一个刷黑颜色和一组纹理定image。该样式设置为Qt.TexturePattern。
See also setTextureImage( ) 。
QBrush.__init__ (self, QGradient gradient)
构造的副本other。
QBrush.__init__ (self, QBrush brush)
构建了基于给定的一个刷gradient。
画笔样式设置为相应的渐变样式(无论是Qt.LinearGradientPattern,Qt.RadialGradientPattern or Qt.ConicalGradientPattern) 。
QBrush.__init__ (self, QVariant variant)
QColor QBrush.color (self)
[
返回画笔颜色。
](docs_qcolor.html)
QGradient QBrush.gradient (self)
[
返回描述此刷的梯度。
bool QBrush.isOpaque (self)
返回True如果刷的是完全不透明的,否则为False 。刷子被认为是不透明的,如果:
](docs_qgradient.html)
- 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.
QMatrix QBrush.matrix (self)
[
返回刷当前变换矩阵。
这个函数中引入了Qt 4.2中。
](docs_qmatrix.html)
QBrush.setColor (self, QColor color)
设置画笔颜色为给定的color。
请注意,调用的setColor ( )将不会有所作为,如果风格是一个梯度。同样的情况下,如果风格Qt.TexturePattern风格,除非当前的纹理是QBitmap。
See also color( ) 。
QBrush.setColor (self, Qt.GlobalColor acolor)
这是一个重载函数。
设置画笔颜色为给定的color。
QBrush.setMatrix (self, QMatrix mat)
Sets matrix作为当前画笔明确的变换矩阵。刷变换矩阵合并QPainter变换矩阵,以产生最终结果。
这个函数中引入了Qt 4.2中。
See also matrix( ) 。
QBrush.setStyle (self, Qt.BrushStyle)
设置画笔样式style。
See also style( ) 。
QBrush.setTexture (self, QPixmap pixmap)
设置画笔像素图来pixmap。该样式设置为Qt.TexturePattern。
当前画笔的颜色只会有单色像素图的效果,即对QPixmap.depth()== 1 (QBitmaps) 。
See also texture( ) 。
QBrush.setTextureImage (self, QImage image)
刷图像设置为image。该样式设置为Qt.TexturePattern。
请注意当前的画笔颜色会not在单色图像有什么影响,而不是调用setTexture( )与QBitmap。如果你想改变单色图像画笔的颜色,可以将图像转换为QBitmap同QBitmap.fromImage()
并设定产生的QBitmap作为纹理,或更改图像中的颜色表中的条目。
这个函数中引入了Qt 4.2中。
See also textureImage()和setTexture( ) 。
QBrush.setTransform (self, QTransform)
Sets matrix作为当前画笔明确的变换矩阵。刷变换矩阵合并QPainter变换矩阵,以产生最终结果。
此功能被引入Qt的4.3 。
See also transform( ) 。
Qt.BrushStyle QBrush.style (self)
[
返回画笔样式。
](docs_qt.html#BrushStyle-enum)
QBrush.swap (self, QBrush other)
掉期刷other用这个刷子。这个操作是非常快的,而且永远不会。
此功能被引入Qt的4.8 。
QPixmap QBrush.texture (self)
[
返回自定义画笔模式,或者如果没有自定义画笔格局已定一个空的像素图。
](docs_qpixmap.html)
See also setTexture( ) 。
QImage QBrush.textureImage (self)
[
返回自定义画笔模式,或者如果没有自定义画笔格局已定一个空的图像。
](docs_qimage.html)
如果纹理被设置为QPixmap它会被转换为一个QImage。
这个函数中引入了Qt 4.2中。
See also setTextureImage( ) 。
QTransform QBrush.transform (self)
[
返回刷当前变换矩阵。
此功能被引入Qt的4.3 。
](docs_qtransform.html)
See also setTransform( ) 。
bool QBrush.__eq__ (self, QBrush b)
bool QBrush.__ne__ (self, QBrush b)