Results 1 to 9 of 9

Thread: cannot convert parameter 1 from 'QVariant' to 'VARIANT'

  1. #1
    Join Date
    Jul 2008
    Posts
    7
    Thanks
    1

    Default cannot convert parameter 1 from 'QVariant' to 'VARIANT'

    hi, why i have this error? there's my code:

    Qt Code:
    1. ao.setControl("geometry.geometryenvironment");
    2.  
    3. IGeometryEnvironmentPtr ipGeoEnviron(CLSID_GeometryEnvironment);
    4. IGeometryFactory2Ptr ipGeomFact(ipGeoEnviron);
    5.  
    6. ao.queryInterface(IID_IGeometryFactory2,(void**)&ipGeomFact);
    7.  
    8. IGeometryPtr ipGeom;
    9.  
    10. QVariant value = query.value(0);
    11.  
    12. if (ipGeomFact){
    13. long bytesRead;
    14. if (ipGeomFact->CreateGeometryFromWkbVariant(value, &ipGeom, &bytesRead)))
    15. }
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. HRESULT CreateGeometryFromWkbVariant(
    2. VARIANT wkb,
    3. IGeometry** outGeometry,
    4. long* numBytesRead
    5. );
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'

    What does the value really contain?

  3. #3
    Join Date
    Jul 2008
    Posts
    7
    Thanks
    1

    Default Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'

    it's a value of a field from database, it's a QByteArray type, and VARIANT for CreateGeometryFromWkbVariant needs dataTypeEnum == adVarBinary

  4. #4
    Join Date
    Jul 2008
    Posts
    7
    Thanks
    1

    Default Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'

    and the database field is a blob type... does QODBC support it?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'

    So it's probably safest to convert it to const char * using toByteArray() and then constData() and then convert it to the VARIANT type.

  6. The following user says thank you to wysota for this useful post:

    loh (16th July 2008)

  7. #6
    Join Date
    Jul 2008
    Posts
    7
    Thanks
    1

    Default Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'

    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?

  8. #7
    Join Date
    Jul 2008
    Posts
    7
    Thanks
    1

    Default Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'

    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.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'

    If you have const char *, you can then cast it to unsigned int*.

  10. #9
    Join Date
    Jul 2008
    Posts
    7
    Thanks
    1

    Default Re: cannot convert parameter 1 from 'QVariant' to 'VARIANT'

    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.

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.