Results 1 to 10 of 10

Thread: dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

  1. #1
    Join Date
    Jul 2012
    Posts
    5
    Qt products
    Qt4

    Default dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

    Hi to all,

    I have to access a COM component method having this signature :
    Qt Code:
    1. HRESULT SetBillValueEnables([in, out] SAFEARRAY(VARIANT_BOOL)* billValueEnables);
    To copy to clipboard, switch view to plain text mode 

    I used the dumpcpp tool to import the type lib header, and according to
    http://doc.qt.io/qt-4.8/http://qt-project.org/doc/qt-4.8/qaxbase.html

    I tried this
    Qt Code:
    1. QList<QVariant> billValuesToDevice;
    2. billValuesToDevice << false << false << false << false << false;
    3. QList<QVariant> parameters;
    4. parameters << billValuesToDevice;
    5. _acc->dynamicCall("SetBillValueEnables(QList<QVariant>*&)",parameters);
    To copy to clipboard, switch view to plain text mode 

    But as result, I receive the error message :
    QAxBase: Error calling IDispatch member SetBillValueEnables: Unknown error

    I first thought that the issue was caused by the COM implementation of the API, so I give it a try with Visual C++, and there it works fine with :
    Qt Code:
    1. SAFEARRAYBOUND bounds;
    2. bounds.cElements = 5;
    3. bounds.lLbound = 0;
    4. SAFEARRAY *pNewValues;
    5. pNewValues = SafeArrayCreate(VT_BOOL,1,&bounds);
    6. short output[5];
    7. for (long i=0; i<5; i++)
    8. {
    9. output[i] = true;
    10. SafeArrayPutElement(pNewValues,&i,&(output[i]));
    11. output[i] = false;
    12. }
    13.  
    14. _pAcceptor->SetBillValueEnables(&pNewValues);
    To copy to clipboard, switch view to plain text mode 
    Can someone please help me with this, or confirm that SAFEARRAY(VARIANT_BOOL)* is not a supported parameter type ?
    Last edited by kenpanda; 4th July 2012 at 11:01.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,387
    Thanks
    247
    Thanked 687 Times in 677 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

    Qt Code:
    1. _acc->dynamicCall("SetBillValueEnables(QList<QVariant>*&)",parameters);
    To copy to clipboard, switch view to plain text mode 

    Maybe your function declaration is incorrect. Try this:

    Qt Code:
    1. _acc->dynamicCall("SetBillValueEnables(QList<QVariant>&)",parameters);
    To copy to clipboard, switch view to plain text mode 

    (Note, no "*" - it is QList<QVariant>& ).

  3. #3
    Join Date
    Jul 2012
    Posts
    5
    Qt products
    Qt4

    Default Re: dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

    I already tried this, but it gives the same error.
    Moreover the signature (QList<QVariant>*&) is coming from the header generated by the Qt dumpcpp tool.
    I attached the generated header to this post.
    Is it possible that there is a bug in this dumpcpp ?
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,387
    Thanks
    247
    Thanked 687 Times in 677 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

    Ah, one other thing: your COM version is different from your Qt version in that you are using a "short" to represent the VT_BOOL arguments in the COM version (which is correct), whereas in Qt you are using a QVariant::Bool type, which probably is 8 bits or less. VT_BOOL is required to be a 16-bit type. In addition, VT_TRUE is defined as 0xFFFF and VT_FALSE as 0x0000. Simply setting the value to C++ "true" is probably incorrect.

  5. #5
    Join Date
    Jul 2012
    Posts
    5
    Qt products
    Qt4

    Default Re: dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

    I know but according the Qt doc, the matching type for VARIANT_BOOL is bool or bool& (depending if [in] or [in|out] parameter)

    Anyway, I changed my test code to this, and I have the same results
    Qt Code:
    1. QList<QVariant> billValuesToDevice;
    2. billValuesToDevice << 0x0000 << 0xFFFF << 0x0000 << 0xFFFF << 0x0000;
    3. QList<QVariant> parameters;
    4. parameters << billValuesToDevice;
    5. _acc->dynamicCall("SetBillValueEnables(QList<QVariant>*&)",parameters);
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,387
    Thanks
    247
    Thanked 687 Times in 677 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

    billValuesToDevice << 0x0000 << 0xFFFF << 0x0000 << 0xFFFF << 0x0000;
    This doesn't mean that your QVariant item contains a "short" (16-bit) integer. Have you looked at the QVariant type to see what it actually contains?

    Have you tried calling one of the COM methods that uses some kind of variable other than VT_BOOL? Like a BSTR (which maps to a QString)? Do those kinds of calls work?

    Do you even know if "_acc" is actually pointing to a COM object instance of the type you think?

    QAxBase: Error calling IDispatch member SetBillValueEnables: Unknown error
    What is the actual error code returned here?

    Do you know that "SetBillValueEnables" is actually the string you need to pass to dynamicCall()? No "_" or something like that required in front of the name? No namespace that you're leaving out?

    Does your COM object allow you to call that method at the time you are calling it (i.e. is there some series of prerequisite methods that must be called first in order to put the object into the right state for this call to work?)

    Everything you are trying is based on the assumption that there is something wrong with the arguments, but it could be something entirely different from that. If you can get a COM method with a different type of argument to work on the same object instance, then you can start to narrow it down to a specific problem.

    Edit:

    I know but according the Qt doc, the matching type for VARIANT_BOOL is bool or bool& (depending if [in] or [in|out] parameter)
    Oops, sorry, missed this before I wrote all that above. So the parameters probably -are- correct, so you are likely calling the method at the wrong time.

    I've just looked at your nmpost.h file. All of the COM classes in there are inherited from QAxObject. You should be able to call the class methods directly - no need for "dynamicCall()".

    So assuming that "_acc" is a pointer to an instance of IAcceptor_API, then why don't you simply do this?

    Qt Code:
    1. _acc->SetBillValueEnables( &parameters );
    To copy to clipboard, switch view to plain text mode 

    (Another observation: why do you make a copy of your QList< QVariant > in "parameters" after you fill the original with values? Why not just pass the original?)
    Last edited by d_stranz; 7th July 2012 at 01:20.

  7. #7
    Join Date
    Jul 2012
    Posts
    5
    Qt products
    Qt4

    Default Re: dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

    Sorry d_stranz,
    I'm currently on holliday, but basically :
    - I do not call SetBillValueEnables because it is not recommended to call it directly. Instead this method is in fact a slot and should be called via a signal. Despite, I already tried this, but it does not work neither.
    - _acc is indeed a pointer to IAcceptor_API
    - I made a copy to "parameters", the way it is described in the QAxObject description (look for the example to call 'fillList');
    in fact there are multiple overload of dynamicCall, each of them with a different number of QVariant parameter (1->8), and a last one with a QVariantList.
    As the first parameter a need to give IS a list of bool, I try to give this array of bool as the first item of the QVariantList.

    I already tried to give use the overload to give the booleans via the overload, no luck


    Thanks for your help, and sorry again for this late reply

  8. #8
    Join Date
    Sep 2011
    Posts
    1,245
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

    "I do not call SetBillValueEnables because it is not recommended to call it directly. Instead this method is in fact a slot and should be called via a signal"
    Don't know where you read that - any slot can be called like a normal member method (after all, that is all that it is).
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  9. #9
    Join Date
    Jul 2012
    Posts
    5
    Qt products
    Qt4

    Default Re: dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

    Don't know where you read that - any slot can be called like a normal member method (after all, that is all that it is).
    I read this from the documentation generated via the QAxObject :

    Qt Code:
    1. QString result = _acc->generateDocumentation();
    To copy to clipboard, switch view to plain text mode 

    :


    void SetBillValueEnables (QVariantList*& billValueEnables) [slot]
    Connect a signal to this slot:
    QObject::connect(sender, SIGNAL(someSignal(QVariantList*&)), object, SLOT(SetBillValueEnables(QVariantList*&)));
    Or call the function directly:
    QVariantList params = ...
    object->dynamicCall("SetBillValueEnables(QVariantList*&)" , params);

  10. #10
    Join Date
    Jan 2013
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall with [in, out] SAFEARRAY(VARIANT_BOOL)* parameter

    Hi,

    I am facing a similar problem. Did you solve this one? How?

    Thanks

Similar Threads

  1. Help dynamicCall()
    By marouan in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2011, 10:15
  2. Using array with QAxWidget::dynamicCall() function
    By tom0485 in forum Qt Programming
    Replies: 1
    Last Post: 17th May 2010, 10:31
  3. Problem calling a routine with dynamicCall
    By franco.amato in forum Qt Programming
    Replies: 10
    Last Post: 10th May 2010, 17:59
  4. Replies: 0
    Last Post: 16th April 2010, 23:21
  5. Replies: 1
    Last Post: 28th May 2008, 16:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.