Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to send an array of double into qt activex component?
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 932 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mark57
    wrote on last edited by
    #1

    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);
    

    }@

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved