Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QAxBase 遇到VARIANT*参数的问题



  • 我使用dynamicCall调用com中的函数,函数有VARIANT* 作为函数参数,
    传参 我尝试了 使用 QVariant& , const QVariant& , const QList<QVariant>& , QList<QVariant>&, const QStringList& , QStringList& , QAxObject* 都得到错误的参数传递。错误如下:
    QAxBase: Error calling IDispatch member GetAll: Type mismatch in parameter 0

    我的qt代码:
    QList<QVariant> PropNames_f,PropTypes_f,PropValues_f;
    array_f = customProperty->dynamicCall("GetAll(QVariant&,QVariant&,QVariant&)",PropNames_f,PropTypes_f,PropValues_f);

    GetAll在com中的原型:
    virtual HRESULT __stdcall GetAll (
    /[in,out]/ VARIANT * PropNames,
    /[in,out]/ VARIANT * PropTypes,
    /[in,out]/ VARIANT * PropValues,
    /[out,retval]/ long * NumProps ) = 0;

    qt对 com类型的部分映射关系(qt帮助提取):
    COM type Qt property in-parameter out-parameter

    BSTR QString const QString& QString&
    SAFEARRAY(VARIANT) QList<QVariant> const QList<QVariant>& QList<QVariant>&
    SAFEARRAY(BYTE) QByteArray const QByteArray& QByteArray&
    SAFEARRAY(BSTR) QStringList const QStringList& QStringList&
    VARIANT type-dependent const QVariant& QVariant&
    IDispatch* QAxObject* QAxBase::asVariant() QAxObject* (return value)
    IUnknown* QAxObject* QAxBase::asVariant() QAxObject* (return value)
    SCODE, DECIMAL unsupported unsupported unsupported
    VARIANT* (Since Qt 4.5) unsupported QVariant& QVariant&

    请求帮忙解决。
    谢谢!


Log in to reply