<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[edit] ActiveQt dynamicCall error: bad parameter count despite the right number]]></title><description><![CDATA[<p dir="auto">Hi guys,<br />
As you can see, I'm new here, and also quite new to Qt.  I'm using it for my BSc thesis since one month.</p>
<p dir="auto">To my problem:<br />
I'm working with sensors, I got a dll for, built with VC++, which provides COM-objects. There's also an IDL file, but no headers. The dumpcpp-approach did not work, as one method returned a null-pointer, so I'm now just using the QAxObjects and dynamicCalls.</p>
<p dir="auto">Queries with one parameter like:<br />
@int setup = dm-&gt;dynamicCall("Setup(const int&amp;)",0).toInt();@<br />
worked fine.</p>
<p dir="auto">No I want to call a method with several parameters, defined in the IDL like this:<br />
@[id(9), helpstring("method GetQuants")] HRESULT GetQuants(LONG SrcIndex, LONG Count, VARIANT* Buffer, LONG DstIndex);@<br />
The VC++ example provided with the dll, does it like this:<br />
@component-&gt;GetQuants(0, count, &amp;buffer, 0);@</p>
<p dir="auto">When I use:<br />
@QList&lt;QVariant&gt; parameters;<br />
parameters &lt;&lt; 0  &lt;&lt; count &lt;&lt; analog_buffer &lt;&lt; 0;<br />
ai-&gt;dynamicCall("GetQuants(QList&lt;QVariant&gt;&amp;)",parameters);@</p>
<p dir="auto">I get:<br />
"QAxBase: Error calling IDispatch member GetQuants: Type mismatch in parameter 0".</p>
<p dir="auto">To make sure I have the right types, I tried something like this:</p>
<p dir="auto">@ai-&gt;dynamicCall("GetQuants(const int&amp;, const int&amp;, const QVariant&amp;, const int&amp;)",0,count,analog_buffer,0);@</p>
<p dir="auto">Here I get the error:<br />
"Error calling IDispatch member GetQuants: Bad parameter count."<br />
Although I'm very sure to have the right number of parameters.</p>
<p dir="auto">Trying this:<br />
@ai-&gt;dynamicCall("GetQuants(0,96,QVariant(buffer),0");@<br />
I get "QAxBase: Error calling IDispatch member GetQuants: Type mismatch in parameter 3", so the first three look like being accepted.</p>
<p dir="auto">I have been using mingw until recently, which was probably a bad idea with the VC compiled dlls , but I just tried the VC compiler instead and got the same errors.<br />
I'm not sure if this is an issue with using several parameters, or a problem with the dll not accessed right by Qt. I hope there is a solution for that. Thanks in advance!</p>
<p dir="auto">gablbart</p>
<hr />
<p dir="auto">My System:<br />
Windows XP SP3<br />
QtCreator 2.0.1<br />
Qt 4.7.2 VS2008</p>
]]></description><link>https://forum.qt.io/topic/4742/edit-activeqt-dynamiccall-error-bad-parameter-count-despite-the-right-number</link><generator>RSS for Node</generator><lastBuildDate>Sun, 01 Nov 2026 23:33:54 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/4742.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 31 Mar 2011 09:56:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [edit] ActiveQt dynamicCall error: bad parameter count despite the right number on Tue, 03 Jul 2012 11:42:36 GMT]]></title><description><![CDATA[<p dir="auto">Sounds like a good suggestion. You might:</p>
<h1>create a bugreport with your suggestion</h1>
<h2>Better yet, a patch</h2>
<h1>for now, create a doc note on this.</h1>
]]></description><link>https://forum.qt.io/post/100957</link><guid isPermaLink="true">https://forum.qt.io/post/100957</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Tue, 03 Jul 2012 11:42:36 GMT</pubDate></item><item><title><![CDATA[Reply to [edit] ActiveQt dynamicCall error: bad parameter count despite the right number on Tue, 03 Jul 2012 11:30:14 GMT]]></title><description><![CDATA[<p dir="auto">I think it's sufficient to add the bold text and the example code to the current QAxBase::dynamicCall documentation as below:</p>
<p dir="auto">QVariant QAxBase::dynamicCall ( const char * <em>function</em>, QList&lt;QVariant&gt; &amp; <em>vars</em> )<br />
This is an overloaded function.<br />
Calls the COM object's method <em>function</em>, passing the parameters in <em>vars</em>, and returns the value returned by the method. <em>Parameters data types must be specified like this:</em></p>
<p dir="auto">@QList&lt;QVariant&gt; varlist;<br />
varlist &lt;&lt; true &lt;&lt; 123 &lt;&lt; 1.2345;<br />
int n = object.dynamicCall("methodToCall(bool,int,double)", varlist).toInt();@</p>
<p dir="auto">If the method does not return a value or when the function call failed this function returns an invalid QVariant object.<br />
The QVariant objects in vars are updated when the method has out-parameters.</p>
]]></description><link>https://forum.qt.io/post/100954</link><guid isPermaLink="true">https://forum.qt.io/post/100954</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 03 Jul 2012 11:30:14 GMT</pubDate></item><item><title><![CDATA[Reply to [edit] ActiveQt dynamicCall error: bad parameter count despite the right number on Mon, 02 Jul 2012 12:04:59 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="SpaceCowboy2" date="1341218265"]Qt documentation of -&gt;dynamicCall() should be reworded in a clearer way...[/quote]<br />
That is a good idea, but do you have a concrete suggestion for that?</p>
]]></description><link>https://forum.qt.io/post/100944</link><guid isPermaLink="true">https://forum.qt.io/post/100944</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Mon, 02 Jul 2012 12:04:59 GMT</pubDate></item><item><title><![CDATA[Reply to [edit] ActiveQt dynamicCall error: bad parameter count despite the right number on Mon, 02 Jul 2012 08:37:45 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I solved the issue too, in a simpler way  (11 parameters):</p>
<p dir="auto">@QList&lt;QVariant&gt; varList;</p>
<p dir="auto">varList &lt;&lt; x &lt;&lt; y &lt;&lt; HFont &lt;&lt; NameEl &lt;&lt; 0 &lt;&lt; 0 &lt;&lt; 0 &lt;&lt; 0 &lt;&lt; 0 &lt;&lt; 0 &lt;&lt; "Text" &lt;&lt; 0 &lt;&lt; 0;</p>
<p dir="auto">Layout-&gt;querySubObject("DrawingObjects()")-&gt;dynamicCall("AddText(double x, double y, double Height, QString Text, double RotationAngle = 0, bool Flipped = 0, QString FontName = 0, bool Bold = 0, bool Italic = 0, bool DrawAsPolygons = 0, QString LayerName = 0, bool UseProcessLayers = 0, QString LayerMapping = 0)",varList);@</p>
<p dir="auto">Qt documentation of -&gt;dynamicCall() should be reworded in a clearer way...<br />
Regards</p>
]]></description><link>https://forum.qt.io/post/100938</link><guid isPermaLink="true">https://forum.qt.io/post/100938</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 02 Jul 2012 08:37:45 GMT</pubDate></item><item><title><![CDATA[Reply to [edit] ActiveQt dynamicCall error: bad parameter count despite the right number on Sat, 30 Jun 2012 01:07:29 GMT]]></title><description><![CDATA[<p dir="auto">Hi SpaceCowboy,<br />
the solution was to switch to the MSVC compiler. You get a free version with Visual Studio Express, but I'm not sure wether it has support for ActiveX/COM stuff. So maybe you need the full version. Good luck!</p>
<p dir="auto">gablbart</p>
]]></description><link>https://forum.qt.io/post/100934</link><guid isPermaLink="true">https://forum.qt.io/post/100934</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sat, 30 Jun 2012 01:07:29 GMT</pubDate></item><item><title><![CDATA[Reply to [edit] ActiveQt dynamicCall error: bad parameter count despite the right number on Wed, 27 Jun 2012 13:06:33 GMT]]></title><description><![CDATA[<p dir="auto">Hi, I Got the exactly the same problem, how do you solve it?</p>
]]></description><link>https://forum.qt.io/post/100930</link><guid isPermaLink="true">https://forum.qt.io/post/100930</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 27 Jun 2012 13:06:33 GMT</pubDate></item><item><title><![CDATA[Reply to [edit] ActiveQt dynamicCall error: bad parameter count despite the right number on Thu, 31 Mar 2011 10:56:06 GMT]]></title><description><![CDATA[<p dir="auto">Hi Gerolf,<br />
thank you for your hints!</p>
<p dir="auto">If I do it like you suggested, I get:</p>
<p dir="auto">"QAxBase: Error calling IDispatch member GetQuants: Bad parameter count"</p>
<p dir="auto">The last example gives me:</p>
<p dir="auto">" 'QVariant::QVariant': cannot access private member declared in class 'QVariant' "</p>
<p dir="auto">I'm not sure, why the VARIANT is a pointer. The VARIANT buffer is filled with a SAFEARRAY by<br />
@[id(10), helpstring("method CreateCompatibleBuffer")] HRESULT CreateCompatibleBuffer(VARIANT* buffer);@<br />
,as the documentation states, before I fill it with GetQuants().</p>
]]></description><link>https://forum.qt.io/post/82039</link><guid isPermaLink="true">https://forum.qt.io/post/82039</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 31 Mar 2011 10:56:06 GMT</pubDate></item><item><title><![CDATA[Reply to [edit] ActiveQt dynamicCall error: bad parameter count despite the right number on Thu, 31 Mar 2011 10:08:30 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I never tried what you are doing, but I have a guess what is wrong:</p>
<p dir="auto">@<br />
ai-&gt;dynamicCall("GetQuants(const int&amp;, const int&amp;, const QVariant&amp;, const int&amp;)",0,count,analog_buffer,0);<br />
@</p>
<p dir="auto">and this</p>
<p dir="auto">@<br />
[id(9), helpstring("method GetQuants")] HRESULT GetQuants(LONG SrcIndex, LONG Count, VARIANT* Buffer, LONG DstIndex);<br />
@</p>
<p dir="auto">does not match. <em>const int&amp;</em> != LONG and VARIANT*!=const QVariant&amp;+</p>
<p dir="auto">I would try the following:</p>
<p dir="auto">@<br />
ai-&gt;dynamicCall("GetQuants(int, int, const QVariant&amp;, int)",0,count,analog_buffer,0);<br />
// or<br />
ai-&gt;dynamicCall("GetQuants(int, int, QVariant&amp;, int)",0,count,analog_buffer,0);<br />
// or<br />
ai-&gt;dynamicCall("GetQuants(int, int, QVariant*, int)",0,count,&amp;analog_buffer,0);<br />
@</p>
<p dir="auto">Do you know, why the VARIANT is a pointer? is it an out parameter?</p>
]]></description><link>https://forum.qt.io/post/82015</link><guid isPermaLink="true">https://forum.qt.io/post/82015</guid><dc:creator><![CDATA[giesbert]]></dc:creator><pubDate>Thu, 31 Mar 2011 10:08:30 GMT</pubDate></item></channel></rss>