Skip to content
Advertisement

Is it possible to paint a QGraphicsItem inside the paint() method?

I’m creating a subclass of QGraphicsItem, and this subclass has different places that the user can click. My idea is for each component clicked to create a subclass of QGraphicsItem with mousePressEvent replaced. The problem is how can I merge this component into a subclass of QGraphicItem.

Here’s the code I’m trying, but I do not know how to show all the components in the paint method.

JavaScript

Advertisement

Answer

Thanks @SimonHibbs , the solution was to call textComponent.setParentItem(self) and ellipseComponent.setParentItem(self) on init method.

Solution:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement