Qt调用COM组件 笔记
来源:互联网 发布:linux kafka 编辑:程序博客网 时间:2024/06/13 12:02
dynamicCall 既可以调用COM方法,也可以设置属性
QVariant QAxBase::dynamicCall ( const char * function, const QVariant & var1 = QVariant(), const QVariant & var2 = QVariant(), const QVariant & var3 = QVariant(), const QVariant & var4 = QVariant(), const QVariant & var5 = QVariant(), const QVariant & var6 = QVariant(), const QVariant & var7 = QVariant(), const QVariant & var8 = QVariant() )
Calls the COM object's method function, passing the parameters var1, var1, var2, var3, var4, var5, var6, var7 and var8, and returns the value returned by the method, or an invalid QVariant if the method does not return a value or when the function call failed.If function is a method of the object the string must be provided as the full prototype, for example as it would be written in a QObject::connect() call.
activeX->dynamicCall("Navigate(const QString&)", "qt.nokia.com");
Alternatively a function can be called passing the parameters embedded in the string, e.g. above function can also be invoked using
activeX->dynamicCall("Navigate(\"qt.nokia.com\")");
All parameters are passed as strings; it depends on the control whether they are interpreted correctly, and is slower than using the prototype with correctly typed parameters.
If function is a property the string has to be the name of the property. The property setter is called when var1 is a valid QVariant, otherwise the getter is called.
activeX->dynamicCall("Value", 5);
QString text = activeX->dynamicCall("Text").toString();
Note that it is faster to get and set properties using QObject::property() and QObject::setProperty().
dynamicCall() can also be used to call objects with a disabled metaobject wrapper, which can improve performance significantely, esp. when calling many different objects of different types during an automation process. ActiveQt will then however not validate parameters.
It is only possible to call functions through dynamicCall() that have parameters or return values of datatypes supported by QVariant. See the QAxBase class documentation for a list of supported and unsupported datatypes. If you want to call functions that have unsupported datatypes in the parameter list, use queryInterface() to retrieve the appropriate COM interface, and use the function directly.
IWebBrowser2 *webBrowser = 0;
activeX->queryInterface(IID_IWebBrowser2, (void **)&webBrowser);
if (webBrowser) {
webBrowser->Navigate2(pvarURL);
webBrowser->Release();
}
This is also more efficient.
QVariant QAxBase::dynamicCall ( const char * function, QList<QVariant> & vars )
This is an overloaded function.
Calls the COM object's method function, passing the parameters in vars, and returns the value returned by the method. If the method does not return a value or when the function call failed this function returns an invalid QVariant object.
The QVariant objects in vars are updated when the method has out-parameters.
void QAxBase::exception ( int code, const QString & source, const QString & desc, const QString & help ) [signal]
This signal is emitted when the COM object throws an exception while called using the OLE automation interface IDispatch. code, source, desc and help provide information about the exception as provided by the COM server and can be used to provide useful feedback to the end user. help includes the help file, and the help context ID in brackets, e.g. "filename [id]".
阅读全文
0 0
- Qt调用COM组件 笔记
- QT调用COM组件
- Qt调用Delphi编写的COM组件
- VC6创建COM组件,Qt调用例子
- C#创建COM组件,QT调用COM组件简单测试(VS2008+QT4.6.4)
- pb 调用com组件
- C#调用COM组件
- java 调用 com组件
- VC调用COM组件
- 调用COM组件方法
- JAVA调用COM组件
- ATL COM 组件 调用
- java调用com组件
- COM组件调用方法
- COM组件调用例子
- VC调用COM组件
- atl com组件调用
- COM组件调用过程
- urllib 结合bs4通过调用selenium-webdriver来爬取jianshu首页文章,并依次阅读前5篇
- struts2_day01_07_struts2配置(package标签)_08_struts2配置(action标签)_09_struts2配置(result标签)
- 210. Course Schedule II(Topological Sort)
- 怎样选择TCP还是选择UDP
- 数据结构--有序List
- Qt调用COM组件 笔记
- 计算机视觉-理论杂谈
- MySQL的安装
- 关于护宝贝开放视频的建议
- python检测404页面
- JS设计模式 -原型模式与构造函数
- 第二十五天总结
- 数据结构习题-一元多项式的加法和乘法
- SSM框架-实现分页和搜索分页