Menu

Qt properties acces

Help
Anthony T.
2009-08-21
2013-04-06
  • Anthony T.

    Anthony T. - 2009-08-21

    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.

     
    • Florian Link

      Florian Link - 2009-08-24

      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.

       
      • Anthony T.

        Anthony T. - 2009-08-31

        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 :-)

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.