How do I set the background color of a brush style

142 Views Asked by At

I tried the following code which gives me an orange crosspattern on white background and I would like it to be blue for example.

brush = QtGui.QBrush()
brush.setColor(QtGui.QColor('orange'))
brush.setStyle(QtCore.Qt.CrossPattern)

scene = QtWidgets.QGraphicsScene()
view = QtWidgets.QGraphicsView(scene)

it = scene.addRect(QtCore.QRectF(0, 0, 400, 400))
it.setBrush(brush)

view.resize(640, 480)
view.show()
1

There are 1 best solutions below

1
On

my work arround was to create a child rectangle with the pattern and a different zvalue.