Hi All,

This post has also been posted at QtForum.org. So sorry for those who already saw it. I guess that both communities are different enough to give me the right to kind of cross-posting.

I'm trying to develop a COM in-process server and an App that uses it. I'm using Qt 4.3 for Windows, commercial license of course.

Both projects compile well, the only COM interface is correctly registered, but here is what I get at runtime:

Qt Code:
  1. QAxBase::setControl: requested control {e2195f4c-620b-4c24-a1af-dc2ee3af1b3f} could not be instantiated
To copy to clipboard, switch view to plain text mode 

This is my first Qt using COM, so I'm not quite sure I'm doing the right thing. Could you guys have a look at what I've done so far? Here is the full source code: TestCOM.zip

First project: Lib

Lib.pro
Qt Code:
  1. TEMPLATE = lib
  2. CONFIG += qt warn_on qaxserver dll
  3. contains(CONFIG, static):DEFINES += QT_NODLL
  4. HEADERS = CDummy.h
  5. SOURCES = main.cpp
  6. RC_FILE = c:/qt/4.3.0/src/activeqt/control/qaxserver.rc
  7. DEF_FILE = c:/qt/4.3.0/src/activeqt/control/qaxserver.def
  8. TARGET = TestCOM
To copy to clipboard, switch view to plain text mode 

CDummy.h
Qt Code:
  1. #ifndef CDUMMY
  2. #define CDUMMY
  3. #include <QtCore>
  4.  
  5. class CDummy : public QObject
  6. {
  7. Q_OBJECT
  8. Q_CLASSINFO("ClassID", "{e2195f4c-620b-4c24-a1af-dc2ee3af1b3f}")
  9. Q_CLASSINFO("InterfaceID", "{88d27a36-8b02-4079-bea2-ebaa083483d2}")
  10.  
  11. // Constructor, destructor
  12. public:
  13. CDummy(QObject * parent = 0)
  14. : QObject(parent)
  15. {
  16. }
  17.  
  18. // Slots
  19. public slots:
  20. QString sayHello(void)
  21. {
  22. return QString("hello world");
  23. }
  24. };
  25.  
  26.  
  27. #endif
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QAxFactory>
  2. #include "CDummy.h"
  3.  
  4. QAXFACTORY_BEGIN("{96732a53-f7cd-477a-a530-7a6a49f12b2b}", "{d4f59aa6-c2e3-4a2e-a1b2-1eb665ec597c}")
  5. QAXCLASS(CDummy)
  6. QAXFACTORY_END()
To copy to clipboard, switch view to plain text mode 

Second project: App

App.pro
Qt Code:
  1. TEMPLATE = app
  2. TARGET = TestCOM
  3. CONFIG += qaxcontainer
  4. TYPELIBS = $$system(dumpcpp -getfile {96732a53-f7cd-477a-a530-7a6a49f12b2b})
  5.  
  6. isEmpty(TYPELIBS) {
  7. message("TestCOM type library not found!")
  8. } else {
  9. SOURCES = main.cpp
  10. }
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QAxObject>
  2. #include <QtCore>
  3. #include "TestCOM.h"
  4.  
  5. int main(int argc, char ** argv)
  6. {
  7. QCoreApplication a(argc, argv);
  8.  
  9. testcomLib::CDummy dummy;
  10. QAxObject object("{e2195f4c-620b-4c24-a1af-dc2ee3af1b3f}");
  11.  
  12. qDebug() << "dummy" << dummy.sayHello();
  13. qDebug() << "object" << object.dynamicCall("sayHello()").toString();
  14.  
  15. return a.exec();
  16. }
To copy to clipboard, switch view to plain text mode 


Cheers!

Fabien