I'am exposing to Pyhton a QObject derived class - Body - having some properties with a custom type, ie the 'pose' property with type 'Pose' (a c++ class).
Those propeties are invisible from Python.
Would anyone have an idea how comes ?
It (probably incorrectly) understood that an Qt property on a QObject derived instance would be seen in Pyhton as an attribute... What did I missed ?
Thanks for you help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hm, one common error is that you need to have a Q_OBJECT macro in your class, otherwise Qt does not generate a MetaObject for your class and thus no properties/signals/slots.
Apart from this, I am not sure if PythonQt supports custom C++ objects for properties, since these are very uncommon as of today. You can always use an accessor method instead of using a property. Keep in mind that you will need to register the C++ class with PythonQt as well.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello I finally solved the problem : PythonQt wasn't implied, only Qt subtleties were...
I am aware of the Q_OBJECT requierment as well of the need for for registering the custom type with :
* Q_DECLARE_METATYPE(MyType) // in .hh
* qRegisterMetaType<MyType>(); // in .cc
But the point is that MyType is a typedef of SomeLibType and that I needed to register under the same syntactic name 'MyType' as unsed in the Q_PROPERTY macros, and not the true type 'SomeLibType'.
Thanks for you answer anyway :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'am exposing to Pyhton a QObject derived class - Body - having some properties with a custom type, ie the 'pose' property with type 'Pose' (a c++ class).
Those propeties are invisible from Python.
Would anyone have an idea how comes ?
It (probably incorrectly) understood that an Qt property on a QObject derived instance would be seen in Pyhton as an attribute... What did I missed ?
Thanks for you help.
Hm, one common error is that you need to have a Q_OBJECT macro in your class, otherwise Qt does not generate a MetaObject for your class and thus no properties/signals/slots.
Apart from this, I am not sure if PythonQt supports custom C++ objects for properties, since these are very uncommon as of today. You can always use an accessor method instead of using a property. Keep in mind that you will need to register the C++ class with PythonQt as well.
Hello I finally solved the problem : PythonQt wasn't implied, only Qt subtleties were...
I am aware of the Q_OBJECT requierment as well of the need for for registering the custom type with :
* Q_DECLARE_METATYPE(MyType) // in .hh
* qRegisterMetaType<MyType>(); // in .cc
But the point is that MyType is a typedef of SomeLibType and that I needed to register under the same syntactic name 'MyType' as unsed in the Q_PROPERTY macros, and not the true type 'SomeLibType'.
Thanks for you answer anyway :-)