QAxObject as an argument for a QAxObject dynamic call?
-
Hello,
I'm using the (awesome) QAxObject/QAxBase framework, but I got stuck in a function where I have to send a QAxObject as an argument of a QAxObject dynamic call.In my specific case, I'm trying Qt with the SAP Business One Data Interface (DI) API (COM), and all is working well for "normal" arguments for the dynamic calls, but I need to send a QAxObject as an argument in some cases.
Here's one example of how it would be in C#, and what I'm doing in Qt:
C#: CompanyService oCompanyService = oCompany.GetCompanyService();
C#: StatesService oStatesService = (StatesService)oCompanyService.GetBusinessService(ServiceTypes.StatesService);QT: QAxObject* stSvc = cmp->querySubObject("GetCompanyService()")->querySubObject("GetBusinessService(int)", 130);
(ServiceTypes is an enum, StatesService = 130)
C#: SAPbobsCOM.State oState = (SAPbobsCOM.State)oStatesService.GetDataInterface (StatesServiceDataInterfaces.ssState);
QT: QAxObject* st = stSvc->querySubObject("GetDataInterface(int)", 0);
(StatesServiceDataInterfaces is an enum, ssState = 0)
C#: oState.Code = "FL";
C#: oState.Country = "US";
C#: oState.Name = "Florida";QT: st->setProperty("Code", "FL");
QT: st->setProperty("Country", "US ");
QT: st->setProperty("Name", "Florida");C#: oStatesService.AddState(oState);
QT: stSvc->dynamicCall("AddState(QVariant)", st); << get a compile error here
I tried this with QVariant and QAxObject (and pointers to) in the prototype, but I always get
'QVariant::QVariant(void*)' is private within this contextTrying to dereference the QAxObject* st also fails to compile.
How can I pass this QAxObject as an argument to the dynamic call?
Thanks!
Joao S Veiga -
Hi jsveiga,
one question: are you using the MS tool chain or do you use mingw for that?
If you use MSVS tool chain, you could also use native COM support (#import) to the the raw COM interface and call it directly. That would also give you the chance to use the enums instead of magic numbers.
If you want to stay in Qt, you could use the "QAxBase::asVariant":http://doc.qt.nokia.com/latest/qaxbase.html#asVariant method which returns the wrapped COM object as QVariant.
-
THANK YOU, THANK YOU GEROLF!!!
"asVariant" did the magic!!
I'm using mingw, "off-the-shelf" Qt SDK, out of stubbornness, laziness, and the hackiness factor of making the API surrender to OSS :-). That compensates the extra quirkiness...
I don't mind the enums; if necessary, I can almost copy/paste them from the ->generateDocumentation() output or SAP B1 documentation.
Many thanks again! You are da man.
Joao S Veiga