Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions

How to generate the documentation for subobject of QAxObject?



  • Hello,
    I'm using the QAxObject/QAxBase framework, but I got stuck in how to know the documentation for the suboject of QAxObject.

    This is my code:

    QAxObject *teObject = new QAxObject;
    teObject->setControl(QString::fromUtf8("{3A4F919D-65A8-11D5-85C1-0001023952C1}")); //SGWorld71
    QString terraString = teObject->generateDocumentation();  //This work, and I got the documentation for "SGWorld71 Class Reference".
    

    In file "SGWorld71 Class Reference", I got the description:

    ....

    Properties:

    • .......

    • IAnalysis71* Analysis;

    • IDateTime71* DateTime;

    • INavigate71* Navigate;

    • IProject71* Project;

    • IProjectTree71* ProjectTree;

    • ......

    "
    And I want to know the reference for the subobject of SGWorld71, for example, IAnalysis71, INavigate71, IProject71, and so on; so I can khow the parameters of QAxBase::dynamicCall() function to call the suboject's method.

    And I use this code:

    QAxObject* anaObject = teObject->querySubObject("Analysis");
    terraString = anaObject->generateDocumentation();  // This doesn't work.
    

    I got this error:
    (error.png

    So what went wrong? And, Is there other way to know the method, properties and other reference of the subobject of one QAxObject?



  • @Wang-xiaohu

    Does it work if you pick one function from here (https://www.skylinesoft.com/hubfs/KB_Resources/TED/Web Help/Programmers Guide/index.htm?#t=Analysis_IAnalysis71.htm) and just call it?

    Is your parent QAxObject still "alive" and valid when you try to access the sub-object?



  • @Pl45m4
    Thanks for your reply. The website you gave is very useful! As a beginner, I don't know whether the the full function prototype from the skylinesoft website (that is the COM component's function prototype) is same with that provided by QAxObject, which wraps the COM object.
    For example, one function in "SGWorld71 Class Reference" generated by Qt is:

    void SetOptionParam(QString paramName, QVariant paramVal);
    

    but in skylinesoft website is :

    HRESULT SetOptionParam(
    
            BSTR paramName,
    
            VARIANT paramVal)
    

    for C++. This function is simple, some other functions may be complex. If I use:

    QVariant QAxBase::dynamicCall(const char *function, QList<QVariant> &vars)
    

    to call the COM object's method function, which requires "If function is a method of the object, the string must be provided as the full prototype", for example,

    activeX->dynamicCall("Navigate(const QString&)", "www.qt-project.org");
    

    the function parameter's data type is Qt data type, so, I probably don't know ”the full function prototype".

    So, I want to use:

    QString QAxBase::generateDocumentation()
    

    to get the documentation for the wrapped COM object, which describes "the full function prototype".

    Second, "Is your parent QAxObject still "alive" and valid when you try to access the sub-object?",
    I think it is. If parent QAxObject is not valid, the should occur this line:

    QAxObject* anaObject = teObject->querySubObject("Analysis");
    

    but now it occurs next line:

    terraString = anaObject->generateDocumentation();
    

    Now, I use:

    #import TerraExplorerX.dll
    

    to generate "terraexplorerx.tlh" and "terraexplorerx.tli". By this way, I have to learn the COM data type and how the object instantiated using class generated by #import, interacts with QAxWidget, which can be embed as windows widget in user application.

    Thank you again for your encouragement!



  • @Pl45m4
    "Is your parent QAxObject still "alive" and valid when you try to access the sub-object?"
    Yes you are right.
    when I added:

         teObject = teObject->querySubObject("Analysis");
         if (!teObject || teObject->isNull()) {
             qDebug() << "NO  subobject!";
         }
    

    the output window: "NO subobject!".

    Why did this function return Null ?

    IAnalysis71 is not the subobject of SGWorld71 ?


Log in to reply