QAxObject, how work with IDispatch?
-
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. -
Hi,
Shouldn't it rather be:
IDispatch * val = object->property("Systems").value<IDispatch*>();
?
-
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 -
Are you sure that you should use IDispatch ? What's the original class you want to access ?
-
If an interface returns IDispatch* then you can create a child QAxObject from it using
querySubObject
.
So instead ofIDispatch * 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 likeItem(int index)
) to access its contents. -
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 -
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 callgenerateDocumentation
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 }
-
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