Skip to content

Brush

Qt Base Class: QBrush

Signature: QBrush(self) -> None QBrush(self, brush: Union[PySide6.QtGui.QBrush, PySide6.QtCore.Qt.BrushStyle, PySide6.QtCore.Qt.GlobalColor, PySide6.QtGui.QColor, PySide6.QtGui.QGradient, PySide6.QtGui.QImage, PySide6.QtGui.QPixmap]) -> None QBrush(self, bs: PySide6.QtCore.Qt.BrushStyle) -> None QBrush(self, color: PySide6.QtCore.Qt.GlobalColor, bs: PySide6.QtCore.Qt.BrushStyle = Instance(Qt.SolidPattern)) -> None QBrush(self, color: PySide6.QtCore.Qt.GlobalColor, pixmap: Union[PySide6.QtGui.QPixmap, PySide6.QtGui.QImage, str]) -> None QBrush(self, color: Union[PySide6.QtGui.QColor, PySide6.QtGui.QRgba64, Any, PySide6.QtCore.Qt.GlobalColor, str, int], bs: PySide6.QtCore.Qt.BrushStyle = Instance(Qt.SolidPattern)) -> None QBrush(self, color: Union[PySide6.QtGui.QColor, PySide6.QtGui.QRgba64, Any, PySide6.QtCore.Qt.GlobalColor, str, int], pixmap: Union[PySide6.QtGui.QPixmap, PySide6.QtGui.QImage, str]) -> None QBrush(self, gradient: Union[PySide6.QtGui.QGradient, PySide6.QtGui.QGradient.Preset]) -> None QBrush(self, image: Union[PySide6.QtGui.QImage, str]) -> None QBrush(self, pixmap: Union[PySide6.QtGui.QPixmap, PySide6.QtGui.QImage, str]) -> None

Base classes

Name Children Inherits
SerializeMixin
prettyqt.utils.serializemixin
QBrush
PySide6.QtGui
QBrush(self) -> None

⋔ Inheritance diagram

graph TD
  1473245597280["gui.Brush"]
  1473299806240["utils.SerializeMixin"]
  140713234304496["builtins.object"]
  1473300183872["QtGui.QBrush"]
  1473291690208["Shiboken.Object"]
  1473299806240 --> 1473245597280
  140713234304496 --> 1473299806240
  1473300183872 --> 1473245597280
  1473291690208 --> 1473300183872
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: SerializeMixin, QBrush

Defines the fill pattern of shapes drawn by QPainter.

Source code in prettyqt\gui\brush.py
class Brush(serializemixin.SerializeMixin, gui.QBrush):
    """Defines the fill pattern of shapes drawn by QPainter."""

    def __repr__(self):
        return get_repr(self, self.get_color(), self.get_style())

    def get_texture_image(self) -> gui.Image | None:
        img = self.textureImage()
        return None if img.isNull() else gui.Image(img)

    def get_color(self) -> gui.Color:
        return gui.Color(self.color())

    def get_style(self) -> constants.BrushStyleStr:
        return constants.BRUSH_STYLE.inverse[self.style()]

    def set_style(self, style: constants.BrushStyleStr | constants.BrushStyle):
        self.setStyle(constants.BRUSH_STYLE.get_enum_value(style))

    def set_transform(self, transform: datatypes.TransformType):
        if isinstance(transform, tuple):
            transform = gui.Transform(*transform)
        self.setTransform(transform)