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. [Solved]ActiveQt: retrieve list of subObjects
Forum Updated to NodeBB v4.3 + New Features

[Solved]ActiveQt: retrieve list of subObjects

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.5k 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.
  • C Offline
    C Offline
    chris17
    wrote on last edited by
    #1

    Hi,

    I need to access a COM-API which has many functions returning Lists of subObjects.

    The functions look like this:
    @public static List<NetworkAdapter> ReadNetworkAdapters();
    @

    Is there a way to do this with dynamicCall() or querySubObject()?

    I have tried the following, but I only get an empty QVariantList
    @
    QVariant var=qxSystem->dynamicCall("ReadNetworkAdapters()");
    qDebug()<<"type:"<<var.typeName();
    qDebug()<<"count:"<<var.toList().count();@

    output:
    type: QVariantList
    count: 0

    Note: I have run the .Net example given by the vendor and it returns 1 NetworkAdapter.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chris17
      wrote on last edited by
      #2

      After looking at the sources of the ActiveQt module I found out that VariantToQVariant only adds items to the list if the type is supported, which is not the case for IUnknown*.

      To make it work for me I added a case for the type VT_Unknown, so it can return a QVariantList which stores IUnknown pointers.

      Here is a snippet of the VariantToQvariant function in qaxtypes.cpp.
      The added code is at line 1351 in the file(Qt 4.8.4)
      @
      void pElement = 0;
      switch(vt) {
      case VT_BSTR: Q_ASSERT(false); break; // already covered
      case VT_BOOL: pElement = &variant.boolVal; break;
      case VT_I1: pElement = &variant.cVal; break;
      case VT_I2: pElement = &variant.iVal; break;
      case VT_I4: pElement = &variant.lVal; break;
      #if defined(_MSC_VER) && _MSC_VER >= 1400
      case VT_I8: pElement = &variant.llVal; break;
      case VT_UI8: pElement = &variant.ullVal; break;
      #endif
      case VT_INT: pElement = &variant.intVal; break;
      case VT_UI1: Q_ASSERT(false); break; // already covered
      case VT_UI2: pElement = &variant.uiVal; break;
      case VT_UI4: pElement = &variant.ulVal; break;
      case VT_UINT: pElement = &variant.uintVal; break;
      case VT_CY: pElement = &variant.cyVal; break;
      case VT_R4: pElement = &variant.fltVal; break;
      case VT_R8: pElement = &variant.dblVal; break;
      case VT_DATE: pElement = &variant.date; break;
      //added this line to support IUnknown

      case VT_UNKNOWN: pElement = &variant.punkVal; break;
      case VT_VARIANT: Q_ASSERT(false); break; // already covered
      default:
      break;
      }
      if (!pElement) {
      var = list;
      break;
      }@

      I am not sure if this is a Bug or just not supported for any reason.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        You can try to ask that on the interest mailing list, you'll find Qt's developers/maintainers there (this forum is more user oriented)

        I don't think it is a bug (I may be wrong though), IIRC IUNKNOWN* can point anything so you don't know what it will be.

        Did you try with registering your custom type with QVariant ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chris17
          wrote on last edited by
          #4

          Thanks, I will ask on the mailing list.

          In my case having a IUnknown* is enough, because then I can create the QAxObject by passing the IUnknown* in the constructor.

          1 Reply Last reply
          0

          • Login

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