Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problems in use of Active Qt
Forum Updated to NodeBB v4.3 + New Features

Problems in use of Active Qt

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 614 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    imlison
    wrote on last edited by
    #1

    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?
    thanks.

    L 1 Reply Last reply
    0
    • I imlison

      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?
      thanks.

      L Offline
      L Offline
      liaoque
      wrote on last edited by
      #2

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

      jsulmJ 1 Reply Last reply
      0
      • L liaoque

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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

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

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved