Passing QByteArray to a callable QJSValue



  • What is the correct way to pass a QByteArray as a parameter to a callable QJSValue?

    Assuming data is binary format.

    QString title = "Intro";
    QByteArray byteArray;
    // read from file into byteArray
    
    QJSValueList args;
    args << title;
    args << byteArray;
    callback.call(args);
    

    The javascript function will be subsequently be passing this to a C++ function for processing.

    Should i be doing this?

    QString title = "Intro";
    QByteArray byteArray;
    // read from file into byteArray
    
    QJSValueList args;
    args << title;
    args << QString::fromLatin1(byteArray.data(), payload.size());
    callback.call(args);
    

Log in to reply
 

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