Menu

Does generator really handle multiple inheritance?

Help
2014-05-29
2014-06-23
  • Alexis Jeandet

    Alexis Jeandet - 2014-05-29

    Hi,

    I spend some time with the generator and I never succeed to wrap a class with more than one base class. Is this example suppose to work?

    class testA
    {
    public:
        testA(){}
        void functionA(){}
    };
    
    class testB
    {
    public:
        testB(){}
        void functionB(){}
    };
    
    class testAB: public testA, public testB
    {
    public:
        testAB(){}
        void functionAB(){}
    };
    

    Here is my xml config file:

    <typesystem package="PySocExplorer" default-superclass="com.trolltech.qt.QtJambiObject">
        <load-typesystem name=":/trolltech/generator/typesystem_core.txt" generate="no" />
        <load-typesystem name=":/trolltech/generator/typesystem_gui.txt" generate="no" />
        <load-typesystem name=":/trolltech/generator/typesystem_network.txt" generate="no" />
        <load-typesystem name=":/trolltech/generator/typesystem_opengl.txt" generate="no" />
        <load-typesystem name=":/trolltech/generator/typesystem_phonon.txt" generate="no" />
        <load-typesystem name=":/trolltech/generator/typesystem_sql.txt" generate="no" />
        <load-typesystem name=":/trolltech/generator/typesystem_svg.txt" generate="no" />
        <load-typesystem name=":/trolltech/generator/typesystem_webkit.txt" generate="no" />
        <load-typesystem name=":/trolltech/generator/typesystem_xmlpatterns.txt" generate="no" />
        <load-typesystem name=":/trolltech/generator/typesystem_xml.txt" generate="no" />
    
        <object-type name="QHexSpinBox" />
        <object-type name="MemSizeWdgt" />
        <object-type name="QHexEdit" />
        <object-type name="XByteArray" />
        <object-type name="SocExplorerPlot" />
        <object-type name="TCP_Terminal_Client" />
        <object-type name="elfparser" />
        <object-type name="abstractExecFile" />
        <object-type name="ElfFile" />
        <object-type name="elfFileWidget" />
        <object-type name="testA" />
        <object-type name="testB" />
        <object-type name="testAB" />
    
    </typesystem>
    

    When I test it can instantiate from python an object from testA,testB and testAB but testAB doesn't expose inherited methods from testA and testB.

    Does any one know how to do that?

    best regards,
    Alexis.

     
  • Alexis Jeandet

    Alexis Jeandet - 2014-05-30

    A small update, I found that if testA is declared as interface in the XML config file like this:

    <interface-type name="testA" />
    

    It works, is it the expected behavior?
    On Qt-Jambi it is more or less explained like this but it wasn't obvious to me that one of the base class had necessary to be declared as interface in the XML conf file.

    Best regards,
    Alexis.

     
  • Alexis Jeandet

    Alexis Jeandet - 2014-05-30

    Hi,

    An other observation, I hope it will help somebody, the include path is really important, for example if your class inherit from QObject you should include like this:

    #include <QtCore/QObject>
    

    The QtCore is mandatory unless you want to add all Qt sub-folders as look-up path while you call pythonqt_generator.

    I don't know if I'm flogging a dead horse but it also wasn't obvious for me.

    Best regards,
    Alexis.

     
  • Florian Link

    Florian Link - 2014-06-02

    Yes, this is a relict of the QtJambi generator, the generator is a fork of the original QtJambi generator.

    Not many people have tried wrapping their own C++ classes with the generator, so it is a good idea to share your experience/problems on this forum.

     
  • Alexis Jeandet

    Alexis Jeandet - 2014-06-23

    Hi,

    I plan to do some kind of wiki with some simple examples, as soon as possible.
    I did also some modifications on PythonQt build scripts, I really prefer to install PythonQt as Qt module than something you embed in each app. Here is a source tree with my modifications(last source with Qt5 support taken on the forum):
    https://hephaistos.lpp.polytechnique.fr/rhodecode/HG_REPOSITORIES/LPP/INSTRUMENTATION/USERS/JEANDET/PythonQt
    So when you want to use PythonQt in your Qt application, you just have to add CONFIG+=pythonqt in your .pro/.pri file.

    Best regards,
    Alexis.

     

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.