Hello,

I try to use ActiveQt and COM-automation. I posted several questions to 
Qt-Forum and stackoverflow but nobody could give me an answer to that topic.
I seems that there is no community for ActiveQt which leads me to the 
assumption that that this library is not much used.

What I want to do is Word-automation and the first thing I did is to create 
wrapper-classes with the tool 'dumpcpp.exe'. That worked
and I could start a new word application, set it visible, create new document, 
etc. Everything worked fine, but when it comes to events,
it was a nightmare.

I found out that I could successfully connect to Events which have no 
parameters like DocumentChange(). Then the Slot is called.
All other events must be handles via the generic signal, because either I could 
not connect to the signal (wrong event signature) or
my slot was not called.
signal(QString<http://qt-project.org/doc/QString.html>,int,void*)

I don't know why it didn't work but the first thing I noticed were the 
different event signatures.

I want to show an example:

First of all, I connect to the generic signal 'signal(QString,int,void*)' to 
handle all event. In the first param (QString), you find the name of the event 
with full signature. In case of word, there is e.g. an event called
DocumentBeforeClose(IDispatch*,bool&)

...when I close a word document. I can see this event in the generic event 
handler. If i directly connect to that signal...
connect(word, SIGNAL(DocumentBeforeClose(IDispatch*,bool&)), this, 
SLOT(onDocumentBeforeClose(IDispatch*,bool&)));

...I get a message:

Object::connect: No such signal 
Word::Application::DocumentBeforeClose(IDispatch*,bool&)

I studied the generated code of the word wrapper classes and I found in the 
metadata string, that the signature is:
DocumentBeforeClose(Document*,bool&)

The same signature above is printed out if I use the QObjects metadata 
information to show all signals. If I connect to this event, there is no output 
on console (no error message) so I thought the connection was successful, but 
my slot is never called (it has no parameter just to make sure that there are 
no problems due to paramter conversion, etc)
connect(word, SIGNAL(DocumentBeforeClose(Document*,bool&)), this, 
SLOT(onDocumentBeforeClose()));
Even if this is working, then I don't know how to define my slot the get the 
two parameters.

By the way: All word events are fired 2 to 4 times, most of them 3 times. This 
is not by design from Ms Word because in Delphi all events are fired exactly 
one time - it
wouldn't make sense to get events more than one time because it makes it hard 
(and impossible) to define a workflow based on such events.

After each event was catched in the generic signal in the console there is a 
message, that there is no signal found, e.g:
Object::receivers: No such signal 
Word::Application::WindowActivate(IDispatch*,IDispatch*)

I don't know why ActiveQt tries to (re)connect (??) to all these events but 
this connect-call was not caused by me.

I faced the same problems when I use the low-level API of ActiveQt without any 
wrapper code!



My environment data:
- Windows 8.1
- Word 2013
- Qt 4.8.5

The same problems exist when I test it on Windows 7 and Word 2010.



My question is: Does/Did somebody use Word automation in ActiveQt and can 
explain how this works with events. Or is it just impossible to use ActiveQt 
and Word
due to internal bugs. The ActiveQt-examples didn't help because there is no 
information about event-handling and I didn't find any code examples for Word 
which
uses events.



Thanks for any help!

Best regards

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to