[PyQt] pyqtproperty with a user type

cabieces julien jcabieces at free.fr
Wed May 20 13:15:22 BST 2009


I need my property to be typed (Vec2 in my example) so pythonproperty would
not help.

in PyQt there is no way to define a new MetaType?

PS : sorry for double post


2009/5/20 cabieces julien <jcabieces at free.fr>

> I need my property to be typed (Vec2 in my example) so pythonproperty would
> not help
>
> in PyQt there is no way to define
>
> 2009/5/20 Phil Thompson <phil at riverbankcomputing.com>
>
> On Wed, 20 May 2009 11:35:04 +0200, cabieces julien <jcabieces at free.fr>
>> wrote:
>> > Hi,
>> >
>> > I would like to use pyqtProperty with a python class that I have
>> defined.
>> > example
>> >
>> > class Vec2(QObject):
>> >   pass
>> >
>> > ....
>> >
>> > class Toto(QObject)
>> >
>> >   def getPos(self):
>> >     return self.__x
>> >
>> >   def setPos(self, x)
>> >     self.__x = x
>> >
>> >   pyqtProperty('Vec2', fget=getPos, fset=setPos)
>> >
>> >
>> > and i get the following error message :
>> > type 'Vec2' is not supported as a property type
>> >
>> > I think I have to register a QMetaType but it seems impossible in PyQt.
>> >
>> > Have you an idea on how I could achieve this.
>>
>> You only need to use pyqtProperty() to define a new Qt property. As Qt
>> doesn't know anything about Python classes then pyqtProperty() wouldn't
>> help.
>>
>> Just use the standard Python property().
>>
>> Phil
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090520/74c1e7e2/attachment.html


More information about the PyQt mailing list