Search code examples
c++qtcomactiveqt

Connecting QAxObject event with a parameter of type IDispatch*


I am trying to use ActiveQt library to handle an ActiveX event which has a parameter of type IDispatch*, such as following in an idl file.

// ...
library RecognitionClientLib
{
    importlib("stdole2.tlb");
    [
        uuid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX),
        helpstring("_IIFactoryEvents Interface")
    ]
    dispinterface _IIRecognizerFactoryEvents
    {
        properties:
        methods:
            [id(1), helpstring("method OnError")] void OnError(
                [in] LONG ilOperationCode,
                [in] BSTR iszDescription
                );
            [id(2), helpstring("method OnResult")] void OnResult(
                [in] IDispatch* ilpSource,
                [in] LONG ilOperationCode
                );
    };
    [
        uuid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX),
        control,
        helpstring("IFactory Class")
    ]
// ...

I used dumpcpp.exe and generated a header file and a cpp file for the object. The generated file skipped the event generation as shown in the header file:

// skipping event interface _IIFactoryEvents

According to the document, IDispatch* argument should be converted to "QAxBase::asVariant()". Hence I tried to connect the events as following:

ClientLib::IFactory* lpFactory(new ClientLib::IFactory());
bool lbOk(connect(
    lpFactory,
    SIGNAL(OnError(
        int,
        const QString&
        )),
    SLOT(onError(
            int,
            const QString&
        ))
    ));
assert(lbOk);
lbOk = connect(
    lpFactory,
    SIGNAL(OnResult(
        QVariant,
        int
        )),
    SLOT(onResult(
        QVariant,
        int
        ))
    );
assert(lbOk);

which I have no problem connecting the signal of OnError but the connection of OnResult failed with

Object::connect: No such signal ClientLib::IFactory::OnResult(QAxObject*,int)

Please help me out on what parameter type should I use for an argument of IDispatch* type?

Many Thanks!


Solution

  • Please help me out on what parameter type should I use for an argument of IDispatch* type?

    IDispatch* maps to QAxObject*: http://doc.qt.io/qt-5/qaxbase.html