PDA

View Full Version : Call ActiveX function with struct parametr



agealex
23rd October 2010, 10:45
I need to call some ActiveX function and one of paramters is a struct

While calling a "segmentation fault" exception raizes



//test.h
#include <ActiveQt/QAxWidget>
#include "windows.h"
#include <QMetaType>
class MapAxWidget : public QAxWidget
{
public:
MapAxWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
void test();
typedef struct
{
long ForeColor;
long BackgroundColor;
}TPWPalette;
}
Q_DECLARE_METATYPE(MapAxWidget::TPWPalette);

//test.cpp

MapAxWidget::MapAxWidget(QWidget* parent, Qt::WindowFlags f )
: QAxWidget(parent, f)
{

setControl({829A0FF0-B154-4CA9-AAD9-3FFF0FA875FE});

}
void MapAxWidget::test()
{
TPWPalette t1;
t1.ForeColor = 1;
t1.BackgroundColor = 1;
QVariant param1;
param1.setValue(t1);
dynamicCall("testMSg(TPWPalette pallet)",param1); //Error raizes here




// qaxbase.cpp
long QAxBase::queryInterface(const QUuid &uuid, void **iface) const
{
*iface = 0;
if (!d->ptr) { //Error shows here
}




If one could help, will be gratefull.

P.S. English is not native language, so i am sorry for mistakes

tbscope
23rd October 2010, 12:35
The following line:

dynamicCall(testMSg("TPWPalette pallet)",param1); //Error raizes here
is completely wrong.

The first parameter is a function name.
You positioned the "" wrong (at least)
Even if the "" are right, there's no function name there.

The second parameter is a QVariant list, not just a QVariant.

agealex
23rd October 2010, 13:51
dynamicCall("testMSg(TPWPalette pallet)",param1); //Error raizes here

Sorry i'v made a mistake when was writting here. The question is the same

and about function. There are 2 prototypes:
QVariant QAxBase::dynamicCall ( const char * function, QList<QVariant> & vars )

QVariant QAxBase::dynamicCall ( const char * function, const QVariant & var1 = QVariant(), const QVariant & var2 = QVariant(), const QVariant & var3 = QVariant(), const QVariant & var4 = QVariant(), const QVariant & var5 = QVariant(), const QVariant & var6 = QVariant(), const QVariant & var7 = QVariant(), const QVariant & var8 = QVariant() )

tbscope
23rd October 2010, 15:14
and about function. There are 2 prototypes:
QVariant QAxBase::dynamicCall ( const char * function, QList<QVariant> & vars )

QVariant QAxBase::dynamicCall ( const char * function, const QVariant & var1 = QVariant(), const QVariant & var2 = QVariant(), const QVariant & var3 = QVariant(), const QVariant & var4 = QVariant(), const QVariant & var5 = QVariant(), const QVariant & var6 = QVariant(), const QVariant & var7 = QVariant(), const QVariant & var8 = QVariant() )

Yes, indeed.
The Qt docs linked to the bottom one which made me think there was only one.