1

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!

crackpot
  • 333
  • 1
  • 2
  • 16
  • Nitpick: const references should be removed from signal/slot signatures you pass to connect, as well as whitespace - this saves a bit of runtime since Qt doesn't have to normalize the signatures. Thus `bool lbOk = connect(lpFactory, SIGNAL(OnError(int,QString)), SLOT(onError(int,QString)));`. – Kuba hasn't forgotten Monica Apr 05 '16 at 13:45
  • Thanks for the advice. I will change them. :) – crackpot Apr 06 '16 at 02:36

2 Answers2

3

I have found out the parameter type should be IDispatch* without modification despite the document said it was QAxBase::asVariant() for in parameter of type IDispatch*.

crackpot
  • 333
  • 1
  • 2
  • 16
1

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

Alexander V
  • 8,351
  • 4
  • 38
  • 47
  • Thanks for your elaborated answer. However my question was what the signature of the signal should I use. I cannot figure out the answer from the above reply though. :( I have dug around and figured out that the argument should be the type of "IDispatch*". The assert passed. Thanks. – crackpot Apr 06 '16 at 02:32