Thanks for your reply.
What I'm looking for is how to create an Assembly or COM component from an QT Application?
I realize that a com component need some kind of GUIID and a need to extract the functions from the application.
This is what I got right now:
#define APPTOLIB_EXPORT Q_DECL_EXPORT
using namespace std;
class APPTOLIB_EXPORT MyMathFuncs
: public QObject{
Q_OBJECT
Q_CLASSINFO("ClassID", "{b50a71db-c4a7-4551-8d14-49983566afee}")
Q_CLASSINFO("InterfaceID", "{4a427759-16ef-4ed8-be79-59ffe5789042}")
Q_CLASSINFO("RegisterObject", "yes")
public:
// Returns a + b
static double Add(double a, double b);
// Returns a / b
// Throws DivideByZeroException if b is 0
static double Divide(double a, double b);
};
{
setObjectName("From QAxFactory");
}
double MyMathFuncs::Add(double a, double b)
{
return a + b;
}
double MyMathFuncs::Divide(double a, double b)
{
if (b == 0)
{
throw new invalid_argument("b cannot be zero!");
}
return a / b;
}
QAXFACTORY_BEGIN("{edd3e836-f537-4c6f-be7d-6014c155cc7a}", "{b7da3de8-83bb-4bbe-9ab7-99a05819e201}")
QAXCLASS(MyMathFuncs)
QAXFACTORY_END()
#define APPTOLIB_EXPORT Q_DECL_EXPORT
using namespace std;
class APPTOLIB_EXPORT MyMathFuncs : public QObject
{
Q_OBJECT
Q_CLASSINFO("ClassID", "{b50a71db-c4a7-4551-8d14-49983566afee}")
Q_CLASSINFO("InterfaceID", "{4a427759-16ef-4ed8-be79-59ffe5789042}")
Q_CLASSINFO("RegisterObject", "yes")
public:
MyMathFuncs(QObject* parent = 0);
// Returns a + b
static double Add(double a, double b);
// Returns a / b
// Throws DivideByZeroException if b is 0
static double Divide(double a, double b);
};
MyMathFuncs::MyMathFuncs(QObject *parent) : QObject(parent)
{
setObjectName("From QAxFactory");
}
double MyMathFuncs::Add(double a, double b)
{
return a + b;
}
double MyMathFuncs::Divide(double a, double b)
{
if (b == 0)
{
throw new invalid_argument("b cannot be zero!");
}
return a / b;
}
QAXFACTORY_BEGIN("{edd3e836-f537-4c6f-be7d-6014c155cc7a}", "{b7da3de8-83bb-4bbe-9ab7-99a05819e201}")
QAXCLASS(MyMathFuncs)
QAXFACTORY_END()
To copy to clipboard, switch view to plain text mode
I can access the interface but I don't get up any functions. I've been able to extract seperate functions but when adding them to a class I only get an interface when adding the reference to my visual studio solution. I which to be able to create a new object of MyMathFuncs and then access the functions which I've made available.
Maybe my title wasn't so well written but what I want is to use my QT c++ class by adding a dll as reference in Visual Studio C# where I can then get hold of the functions/classes which I have made extern.?
Bookmarks