[PyQt] QGraphicsObject / assignProperty

Phil Thompson phil at riverbankcomputing.com
Fri Apr 9 22:37:37 BST 2010


On Fri, 9 Apr 2010 22:44:05 +0200, Philippe Crave
<philippe.crave at gmail.com>
wrote:
> Hi,
> 
> in a QGraphicsObject, I use a StateMachine.
> I have problem using assignProperty.
> I am sure to enter that State, but, it does not change my Class property.
> 
> this how I assign the property
>     self.state_in.assignProperty(self, "alpha", 0)
> 
> and here is how I define the property in the Class
>     def get_alpha(self):
>         print 'get'
>         return self._alpha
>     def set_alpha(self, v):
>         print 'set'
>         self.setOpacity(v)
>         self._alpha = v
>     alpha=property(get_alpha, set_alpha)
> 
> What am I doing wrong ?

Python properties and Qt properties are different things.

Try using pyqtProperty() instead of property().

Phil


More information about the PyQt mailing list