How to send an array of double into qt activex component?



  • I write activex component (using Qt). How to send an array of double into qt activex component from с++ mfc-application (or с++ winapi-application) ? If you do through QByteArray, there is a type mismatch error . Through QVariant not work, sent an empty array.

    There are two ways. Both ways do not work.

    1. through QByteArray

    @void MyQtActivex::setData(QByteArray &_data, int len)
    {
    float* mydata = (float*)(_data.constData());
    .....
    }@

    @void CmsvctestDlg::OnBnClickedButton1()
    {
    SAFEARRAY pSA;
    SAFEARRAYBOUND sab[1];
    sab[0].lLbound = 0;
    sab[0].cElements = len
    4;

    pSA = SafeArrayCreate (VT_ARRAY | VT_UI1, 1, sab);
    SafeArrayAccessData (pSA, (void **) &pData);
    
    memcpy (pData, (BYTE*)_data, len*4);
    
    _myQtActivex.setData((SAFEARRAY ** )pSA->pvData, len);
    

    }@

    1. through QVariant

    @void MyQtActivex::setData(QVariant& psaArray, int _len)
    {
    VARIANT newYVals;
    SAFEARRAY* psaYVals;
    QByteArray _type("double");
    bool _ok = QVariantToVARIANT(psaArray, newYVals, _type);
    ....
    ....
    }@

    @void CmsvctestDlg::OnBnClickedButton1()
    {
    COleSafeArray arry;
    arry.CreateOneDim(VT_R8, len);
    long i;
    for(i=0; i<len; i++)
    {
    double _z = oscp_data_32f[i];
    arry.PutElement(&i, &_z);
    }

    _myQtActivex.setData( COleVariant(arry), len);
    

    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.