ActiveQt user defined type
-
Using Qt 4.7.1
How do I expose an user defined data type in ActiveQt? The ActiveQt will be used in a .NET forms as an ActiveX.
Below is a short example of what I am trying to accomplish. The header files have been removed for brevity. The code compiles fine.
I notice that that an idl file is generate when building the project, inside this file this line is found:
/****** Property is of unsupported datatype
[id(40)] CustomData MyCustomData;Adding the COM component in vs2005 project, I am able to create the SimpleActiveQt object but the CustomData property is not available.
Adding Q_PROPERTY with a basic types like QString works fine in VS2005. So how do I expose the CustomData object?
Do I need to make is derive from QObject and add Q_CLASSINFO meta data like the SimpleActiveQt class?[code]
// main.cpp
QT_USE_NAMESPACE
QAXFACTORY_BEGIN("{00205AD1-F27C-40f9-8A09-203E5B7B01BA}", "{B567AFA4-CA0F-4af2-9CDC-21D0280EB23A}")
QAXCLASS(SimpleActiveQt)
QAXFACTORY_END()// ax1.h
class CustomData
{
QString m_name;
QDate dob;
bool married;
int kids;
};//! [0]
class SimpleActiveQt : public QWidget
{
Q_OBJECT
Q_CLASSINFO("ClassID", "{D3AE74DD-FB3E-4e3f-95FE-CBC11C78E0E0}")
Q_CLASSINFO("InterfaceID", "{E05DBDB2-7628-4275-BC7C-E847E81423F5}")
Q_CLASSINFO("EventsID", "{F7BF220F-F142-4f67-9577-6EC3A602C9FF}")
Q_PROPERTY(CustomData MyCustomData READ getCustomData WRITE setCustomData)
public:
SimpleActiveQt(QWidget *parent = 0) : QWidget(parent)
{
// ctor
}void setCustomData(CustomData cd) { // tbd } CustomData getCustomData() { return m_CustomData; }
private:
CustomData m_CustomData;
};
//! [0][/code]
-
Doing some more investigation it appear that idc.exe generates an idl file based on the activeqt binary file which in this case is a dll. The .idl file contain definitions of some Qt's data types(QRect, QSize and QPoint). An example of the format;
@
[uuid(34569876-5566-4321-5678-6787-67567575675)]
Struct QRect {
int left;
int top
int right;
int bottom;
}
@So I was thinking that if idc.exe could create a similar data type for the class CustomData and place it in the idl file, the MyCustomData property might be available from the .NET project. Does that sound reasonable?
If yes, how does the idc.exe convert QRect into an idl format as seen above?[EDIT: code formatting, Volker]