PDA

View Full Version : QAxContainer: can't instantiate control



fabien
24th July 2007, 11:22
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:


QAxBase::setControl: requested control {e2195f4c-620b-4c24-a1af-dc2ee3af1b3f} could not be instantiated

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 (http://www.qtforum.org/attachment.php?attachmentid=1257)

First project: Lib

Lib.pro

TEMPLATE = lib
CONFIG += qt warn_on qaxserver dll
contains(CONFIG, static):DEFINES += QT_NODLL
HEADERS = CDummy.h
SOURCES = main.cpp
RC_FILE = c:/qt/4.3.0/src/activeqt/control/qaxserver.rc
DEF_FILE = c:/qt/4.3.0/src/activeqt/control/qaxserver.def
TARGET = TestCOM


CDummy.h

#ifndef CDUMMY
#define CDUMMY
#include <QtCore>

class CDummy : public QObject
{
Q_OBJECT
Q_CLASSINFO("ClassID", "{e2195f4c-620b-4c24-a1af-dc2ee3af1b3f}")
Q_CLASSINFO("InterfaceID", "{88d27a36-8b02-4079-bea2-ebaa083483d2}")

// Constructor, destructor
public:
CDummy(QObject * parent = 0)
: QObject(parent)
{
}

// Slots
public slots:
QString sayHello(void)
{
return QString("hello world");
}
};


#endif


main.cpp

#include <QAxFactory>
#include "CDummy.h"

QAXFACTORY_BEGIN("{96732a53-f7cd-477a-a530-7a6a49f12b2b}", "{d4f59aa6-c2e3-4a2e-a1b2-1eb665ec597c}")
QAXCLASS(CDummy)
QAXFACTORY_END()


Second project: App

App.pro

TEMPLATE = app
TARGET = TestCOM
CONFIG += qaxcontainer
TYPELIBS = $$system(dumpcpp -getfile {96732a53-f7cd-477a-a530-7a6a49f12b2b})

isEmpty(TYPELIBS) {
message("TestCOM type library not found!")
} else {
SOURCES = main.cpp
}


main.cpp


#include <QAxObject>
#include <QtCore>
#include "TestCOM.h"

int main(int argc, char ** argv)
{
QCoreApplication a(argc, argv);

testcomLib::CDummy dummy;
QAxObject object("{e2195f4c-620b-4c24-a1af-dc2ee3af1b3f}");

qDebug() << "dummy" << dummy.sayHello();
qDebug() << "object" << object.dynamicCall("sayHello()").toString();

return a.exec();
}



Cheers!

Fabien