[英]how to change color of QGraphicsEllipseItem when it selected?
i use python 2.7 + pyqt4.8 我使用python 2.7 + pyqt4.8
i create many items like QGraphicsEllipseItem
and QGraphicsRectItem
in my scene. 我在场景中创建了许多像
QGraphicsEllipseItem
和QGraphicsRectItem
这样的项目。 I made them all different colors. 我把它们都做成了不同的颜色。 the allocation of the elements around them appears bounding rect, and I would like that they also changed the fill color to another color (white).
它们周围元素的分配似乎是有界的,我希望它们也将填充颜色更改为另一种颜色(白色)。 When removing the selection to return to the original color.
删除选择时,将返回到原始颜色。
how to change color of QGraphicsEllipseItem
when it selected? 选择后如何更改
QGraphicsEllipseItem
颜色?
You should trigger your QGraphicsEllipseItem
"clicked" signal with a handler method which we call it here ellipseClickHandler
where you change the color of your ellipse item by calling its setBrush method like this for instance: 您应该使用处理程序方法触发
QGraphicsEllipseItem
“ clicked”信号,我们在这里将其ellipseClickHandler
,您可以在其中通过调用像这样的setBrush方法来更改椭圆项的颜色:
def ellipseClickHandler(self, ellipseItem)
ellipseItem.setBrush(QBrush(QtCore.Qt.red, style = QtCore.Qt.SolidPattern))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.