Undocumented feature : QAxBase and void/missing parameter(s) to COM Objects functions



  • 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 parameter

    querySubObject("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 parameter

    People 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.html

    I 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


  • Lifetime Qt Champion

    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.



  • Thank you for your answer, OK then I'll try do it today ;)

    Bye


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.