Qt World Summit: Submit your Presentation

Problems in use of Active Qt

  • Good evening,everyone.I am learning Active Qt module, but there are something wrong with special parameters in Com objects.
    For example,this is a interface provided by a Com object:
    @STDMETHODIMP CQtTest::AddSubMethod(long sum, VARIANT* oper1, VARIANT* oper2, long* ret)
    *ret = 0;
    if(oper1->vt != VT_I4)
    ::MessageBox(NULL,L"the frist param error",L"QtTest",0);
    } else if(oper2->vt != VT_I4) {
    ::MessageBox(NULL,L"the second param error",L"QtTest",0);
    } else {
    oper1->lVal = sum + 1;
    oper2->lVal = sum - 1;
    *ret = 1;
    return S_OK;

    It usually can be described as
    @long AddSubMethod(
    [in] long sum,
    [in, out] VARIANT* oper1,
    [in, out] VARIANT* oper2);@

    According to the Qt document, VARIANT* is maped to QVariant&, so I try to use it as follow
    @ int sum = 5;
    int x = 0, y = 0;
    QVariant v_x, v_y;
    v_x.setValue(x); v_y.setValue(y);
    int ret = obj.dynamicCall("AddSubMethod(long,QVariant&,QVariant&)", sum, v_x, v_y).toInt();
    x = (1 == ret ? v_x.toInt() : -1);
    y = (1 == ret ? v_y.toInt() : -1);@

    Howerver,it did not work.
    What was wrong and how to use it correctly while the parameters are VARIANT* type?

  • @imlison Hello, have you solved your problem? I also have this problem now. Can you help me?

  • Lifetime Qt Champion

    @liaoque I suggest you open your own thread as this one is already 6 years old.

Log in to reply