如何将QLinearGradient()
添加到Qrect()
。我只能添加纯色作为Qt.black
等。示例代码:
class ItemClass(QGraphicsItem):
def __init__()
super(ItemClass, self).__init__()
#
def boundingRect(self):
return QRectF(x, y, w, h)
def paint(self, painter, opt, w):
rec = self.boundingRect()
painter.fillRect(rec, #Here I need gradient ramp)
您可以直接传递
QLinearGradient
,如下所示:相关问题 更多 >
编程相关推荐