Qt ActiveX dynamicCall: bad parameter count

别等时光非礼了梦想. 提交于 2019-12-12 10:26:44

问题


I am trying to use an ActiveX control in my program.

QAxWidget* mAX = new QAxWidget();
mAX->setControl("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}");

I know that there is a function:

put_ChannelType(long newValue)

But when I try to execute it:

mAX->dynamicCall("put_ChannelType(long)",2);
mAX->dynamicCall("put_ChannelType(int)",2);
mAX->dynamicCall("put_ChannelType(long)",QVariant(2));
mAX->dynamicCall("put_ChannelType(int)",QVariant(2));

I get:

QAxBase: Error calling IDispatch member put_ChannelType: Bad parameter count

Any idea what is going wrong ?

EDIT:

Weird thing is if I call

mAX->dynamicCall("put_ChannelType()");

I do not get any error message...

EDIT 2:

This also fails (as Constantin suggested)

QList<QVariant> varlist;
varlist << (int)1;
mAX->dynamicCall("put_ChannelType(int)",varlist);

回答1:


Got this solved using the generateDocumentation() function.

I was using this ActiveX control in another application, but an MFC one.

It seems the function names I was referring to (which were in a machine generated IDispatch wrapper class created by VS) were not the same as the ones Qt listed.

i.e. put_ChannelType is actually SetChannelType...

Maybe this is just a version issue ?

Anyways, important part is knowing that generateDocumentation() can list you all the functions you can call with dynamicCall.




回答2:


Is it OK? mAX->dynamicCall("put_ChannelType(const QVariant &)", (long)2);



来源:https://stackoverflow.com/questions/14859552/qt-activex-dynamiccall-bad-parameter-count

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!