PDA

View Full Version : cannot convert parameter 1 from 'QVariant' to 'VARIANT'



loh
16th July 2008, 00:07
hi, why i have this error? there's my code:


QAxObject ao;
ao.setControl("geometry.geometryenvironment");

IGeometryEnvironmentPtr ipGeoEnviron(CLSID_GeometryEnvironment);
IGeometryFactory2Ptr ipGeomFact(ipGeoEnviron);

ao.queryInterface(IID_IGeometryFactory2,(void**)&ipGeomFact);

IGeometryPtr ipGeom;

QVariant value = query.value(0);

if (ipGeomFact){
long bytesRead;
if (ipGeomFact->CreateGeometryFromWkbVariant(value, &ipGeom, &bytesRead)))
}

VARIANT type is supported COM datataype, but as i understand it's supported only with calling methods using dynamicCall, i cant use dynamicCall because there's parameters of unsupported datatypes in CreateGeometryFromWkbVariant function:


HRESULT CreateGeometryFromWkbVariant(
VARIANT wkb,
IGeometry** outGeometry,
long* numBytesRead
);

so maybe i need to convert QVariant to VARIANT, but how?

wysota
16th July 2008, 00:17
What does the value really contain?

loh
16th July 2008, 00:50
it's a value of a field from database, it's a QByteArray type, and VARIANT for CreateGeometryFromWkbVariant needs dataTypeEnum == adVarBinary

loh
16th July 2008, 09:23
and the database field is a blob type... does QODBC support it?

wysota
16th July 2008, 10:44
So it's probably safest to convert it to const char * using toByteArray() and then constData() and then convert it to the VARIANT type.

loh
16th July 2008, 11:59
yes, i'v tried it but, hr = ipGeomFact->CreateGeometryFromWkbVariant(value, &ipGeom, &bytesRead)) gives negative result

i've found another problem: VARIANT must be an array of usigned int type. toByteArray() gives an array of bytes which i must somehow convert to uint, and then make char* containing uint's?

loh
16th July 2008, 12:59
that strange! i have an arrays in the field from msaccess db using QODBC of size 32 indexes bigger then from the same filds using ado and mfc, and the values of the arrays equals correspondingly only at the some first indexes.

wysota
16th July 2008, 13:31
If you have const char *, you can then cast it to unsigned int*.

loh
16th July 2008, 15:05
yeap, i'v casted it to byte - unsigned char. thats no problem.

the problem is that recieved data from blob field from database is incorrect, precisley it is correct only in some bytes of bytes array. the size of the recivied array is also incorrect.