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. QAxObject, how work with IDispatch?
Forum Updated to NodeBB v4.3 + New Features

QAxObject, how work with IDispatch?

Scheduled Pinned Locked Moved General and Desktop
qaxobject
8 Posts 3 Posters 6.2k Views 3 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.
  • M Offline
    M Offline
    marceloarguello700
    wrote on 22 Apr 2015, 18:51 last edited by marceloarguello700
    #1

    I have a dll with Com object, I can instantiate the object and work with it but have a problem with a collection.

    Reading the .generateDocumentation() of QAxObject, see that one method of com dll give me IDispatch pointer:

    IDispatch * val = object->property("Systems").toIDispatch*();
    When work with the same object in Visual Basic,
    the method retrieve a collection of item "System"
    And the class "System" is defined in the DLL.

    In Visual Basic do:
    Dim system As DataSystemFilelib.System
    Set system = obj.systems().items(1)

    I need to load one item of the collection:
    How declare the "System" class in QT
    Also when compile give:
    error: 'class QVariant' has no member named 'toIDispatch'
    So,How can work wit this.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 23 Apr 2015, 10:53 last edited by
      #2

      Hi,

      Shouldn't it rather be:

      IDispatch * val = object->property("Systems").value<IDispatch*>();

      ?

      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
      • M Offline
        M Offline
        marceloarguello700
        wrote on 23 Apr 2015, 11:25 last edited by marceloarguello700
        #3

        Thanks for the reply, Now compile ok,
        the next is how work with the Idispach,
        The property give me a Collection of System class, I need to retrieve Items, work with their,
        also the items have properties with another Collections.
        how i declare the system class?
        Dim system As DataSystemFilelib.System
        Set system = obj.systems().items(1)
        Greetings

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 24 Apr 2015, 21:55 last edited by
          #4

          Are you sure that you should use IDispatch ? What's the original class you want to access ?

          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 Online
            C Online
            Chris Kawa
            Lifetime Qt Champion
            wrote on 25 Apr 2015, 12:48 last edited by Chris Kawa
            #5

            If an interface returns IDispatch* then you can create a child QAxObject from it using querySubObject.
            So instead of

            IDispatch * val = object->property("Systems").value<IDispatch*>();
            

            you can do

            QAxObject* val = object->querySubObject("Systems");
            

            You can then generateDocumentation on that object to see what kind of access it provides (usually something like Item(int index)) to access its contents.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              marceloarguello700
              wrote on 28 Apr 2015, 17:17 last edited by
              #6

              Thanks for the reply
              SGaist:
              I dont want to work with IDispatch because is treacky complicated.
              Just want to transform one old Visual Basic 6 source to my new qt app.
              The original class is defined in the dll like: DataSystemFilelib.System
              then i do: Dim system
              As DataSystemFilelib.System
              and get the first item:
              Set system = obj.systems().items(1)

              Chris Kawa:
              Your answer is not clear to me,
              In the last code lines your assign twice time the val?
              how be the correct way?
              can provide a sample to retrieve the firt item, or the count items?
              The documentation only provide way to work with numbers or string but dont
              provide sample of how do this.
              Greetings

              1 Reply Last reply
              0
              • C Online
                C Online
                Chris Kawa
                Lifetime Qt Champion
                wrote on 28 Apr 2015, 17:52 last edited by Chris Kawa
                #7

                In the last code lines your assign twice time the val?

                What? You should read the text between the code :) I said that you can do the second line instead of the first one. Not both of them.
                QAxObject wraps around IDispatch. As I said, you can call generateDocumentation on the QAxObject to get a documentation of what interface the object provides and code snippets of how to access them.
                I don't know the exact interface of these types so I can only guess, and it probably goes something like this (don't expect to work if you just copy/paste it):

                QAxObject obj("Whatever.the.obj.is.in.your.example");
                QAxObject* systems = ob.querySubObject("Systems");
                int numberOfItems = systems->property("Count").toInt();
                if(numberOfItems > 0)  {
                    QAxObject* firstSystem = systems->querySubObject("Item(int)", 1);
                    //do something with firstSystem
                }
                
                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  marceloarguello700
                  wrote on 4 May 2015, 15:06 last edited by
                  #8

                  Chris Kawa:
                  Thank, Now it work, sorry for the misunderstanding "So instead of:"
                  i get in this trouble because i read the generatedDocumentation()
                  ´IDispatch * val = object->property("Systems").toIDispatch*();´

                  Lack of knowledge and lack of samples.
                  Greetings

                  1 Reply Last reply
                  0

                  5/8

                  25 Apr 2015, 12:48

                  • Login

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