[PyQt] QGraphicsObject / assignProperty

Philippe Crave philippe.crave at gmail.com
Sat Apr 10 08:18:42 BST 2010


you mean:
alpha=pyqtProperty(get_alpha, set_alpha)

produce:
TypeError: type 'function' is not supported as a property type

should I import something specific ?
here are my actual import
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtSvg import *

2010/4/9 Phil Thompson <phil at riverbankcomputing.com>

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100410/f5a32735/attachment.html>


More information about the PyQt mailing list