Undocumented feature : QAxBase and void/missing parameter(s) to COM Objects functions
-
wrote on 28 Dec 2016, 16:23 last edited by deleted426
Hi everybody,
I spent a lot of hours yesterday, trying and reading everywhere that it was impossible to do so. But I had no possible workaround.
I succeeded, doing something very simple at the end, but that is not written anywhere into the documentation or any old discussion of people who all gave up at the end.Sometimes you should call, on a given COM object, something like.
QAxObject* subObject = (QAxObject*)ParentObject->querySubObject("Item(QVariant Name, QVariant Index)", Name, Index)
But you should enter only Name or Index. In my case no Name was possible so I should ask for Index 0 without giving any name. (not even "null", "", any int or anything : nothing). Parameters taken by "querySubObject" are QVariant but no QVariant available Type nor value did the job of "non arguments"
In fact the only possible existing variable in C++ that does the job is described here but not compatible with Qt QAxObjets : "vtMissing"
https://msdn.microsoft.com/en-us/library/ms675103(v=vs.85).aspx (search for "missing")
It's a VARIANT where the type is VT_ERROR and value is DISP_E_PARAMNOTFOUND
Event VARIANTtoQVariant doesn't do the correct conversion (it gives a type QVariant::Invalid but it's not the same and it doesn't work)The solution is the following :
You can enter parameters into the string given to querySubObject, for example :
querySubObject("Item("item1234", 2)");
Then if you want to give a non-parameter you should enter "void" as parameterquerySubObject("Item(void, 0)");
or
querySubObject("Item(void, QVariant)", 0, 0); //The first 0 is ignored (first parameter is void), the second 0 is used as second parameterPeople who never found the solution :
http://www.qtforum.org/article/29157/write-in-excel-file-problem.html
http://www.qtcentre.org/archive/index.php/t-46748.html
http://www.qtcentre.org/archive/index.php/t-46885.htmlI was about to give up when I finally found the solution by trying eveything.
Is it possible to document it into QAxBase documentation about querySubObject and dynamicCall ?Thank you in advance !
Julien
-
Hi and welcome to devnet,
Sure it's possible ! You can even do it yourself :)
You can modify the module's documentation and submit your work for inclusion through gerrit.
-
wrote on 29 Dec 2016, 08:42 last edited by
Thank you for your answer, OK then I'll try do it today ;)
Bye
1/3