I am developing a C++/Qt application that communicates with an ActiveX server. I try to use a function that returns a reference to an array of floats as a parameter. The function prototype is:
Frequencies([in, out] SAFEARRAY(float)*)
My code is:
QList<QVariant> variantList;
object->dynamicCall("Frequencies(QList<QVariant>&)", variantList);
But unfortunately I have the following error: Type Mismatch in Parameter. Pass an array of type string or real.
After reading this document I also tried QList<QString>&
and QList<float>&
with no success.
The documentation of the ActiveX server says: Use a safearray of strings (VT_BSTR) or reals (VT_R8 for double or VT_R4 for float).
Any idea?
Thanks!
The Qt example doesn't show how to read the results. It was my problem...
QList<QString> values;
for(int i=0; i<nbFrequencies; i++) {
values << "0.0";
}
QList<QVariant> variantList;
parameters << QVariant(values);
object->dynamicCall("Frequencies(QList<QString>&)", variantList);
values = variantList.first().toStringList();
for(int j=0; j<values.size(); j++) {
qDebug() << values.at(j);
}
It is necessary to read the first element of variantList
and to convert it to a QStringList
. Very simply...