Help with using QAxAggregated



  • Hi all.
    Please help with using QAxAggregated.
    I need to build in-proc COM server dll, with inheritance of existing interface provided in TLB file.
    I make something like the "OpenGL Example (ActiveQt)":http://qt-project.org/doc/qt-4.8/activeqt-opengl.html, and successfully compile code.
    But client cannot see any method from inherited interface. How to access them?
    @
    // plugapi.cpp
    //...
    #import "GAPI.tlb" no_implementation
    using namespace GAPI;
    //....
    // inheritance from external interface IPluginOutside from TLB
    //
    class AxPluginOutsideImpl : public QAxAggregated, public IPluginOutside {
    public:
    AxPluginOutsideImpl() {}

    long queryInterface(const QUuid &iid, void **iface);
    QAXAGG_IUNKNOWN
    
    BSTR STDMETHODCALLTYPE Get_Name(void);
    BSTR STDMETHODCALLTYPE Get_Version(void);
    uint STDMETHODCALLTYPE ExecuteTicket(long Ticket);
    

    };

    // class which i need to expose for clients
    //
    class GQPlugin : public QObject, public QAxBindable {
    Q_OBJECT
    Q_CLASSINFO("ClassID", "{3c126a91-a880-4a42-b37c-c9041b1946bc}")
    Q_CLASSINFO("InterfaceID", "{D8D09E0D-8C9B-4590-B8F1-5C9216767093}")
    Q_CLASSINFO("EventsID", "{609c58cb-4811-4d45-bf11-a895e2349e83}")
    public:
    GQPlugin(QObject *parent = 0);

    QAxAggregated *createAggregate(){ return new AxPluginOutsideImpl(); }
    

    };
    @

    @
    // plugapi.cpp realisation
    // ...
    #import "GAPI.tlb" implementation_only
    #define QIID_IPluginOutside QUuid(__uuidof(IPluginOutside))

    GQPlugin::GQPlugin(QObject *parent): QObject(parent){}

    long AxPluginOutsideImpl::queryInterface(const QUuid &iid, void **iface){

    *iface = 0;
    
    if ( iid == QIID_IPluginOutside )
        *iface =    (IPluginOutside*) this;
    else
        return E_NOINTERFACE;
    
    AddRef();
    return S_OK;
    

    }

    BSTR STDMETHODCALLTYPE AxPluginOutsideImpl::Get_Name(void)
    { return L"GQPlugin.1.0"; }

    BSTR STDMETHODCALLTYPE AxPluginOutsideImpl::Get_Version(void)
    { return L"1.0"; }

    uint STDMETHODCALLTYPE AxPluginOutsideImpl::ExecuteTicket( long Ticket )
    { return 1; }
    @

    @
    // com server main.cpp
    // ...
    QAXFACTORY_BEGIN("{43f39e41-f171-42d9-884e-7bb029a8bb16}",
    "{a1eaf125-2906-4ff7-99ba-3c993408520a}")
    QAXCLASS(GQPlugin)
    QAXFACTORY_END()
    @

    @
    // client.cpp
    // ..
    QAxObject axgp;

    // GQPlugin class id
    axgp.setControl( "{3c126a91-a880-4a42-b37c-c9041b1946bc}" );  
    
    // trying to call method of inherited interface 
    qDebug() << axgp.dynamicCall("Get_Name");                             
    

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.