Are there any news concerning your approach?
If you only want to use the operator[], something like this may help:
QScriptEngine *engine = new QScriptEngine();
QScriptValue array = engine->newArray(byteArray.size())
for (int i = 0; i < byteArray.size(); ++i)
array.setProperty(i, QScriptValue(engine, byteArray[i]);
QScriptEngine *engine = new QScriptEngine();
QByteArray byteArray;
QScriptValue array = engine->newArray(byteArray.size())
for (int i = 0; i < byteArray.size(); ++i)
array.setProperty(i, QScriptValue(engine, byteArray[i]);
To copy to clipboard, switch view to plain text mode
The QScriptValue can then be handed over to the engine. However, the drawbacks of this approach are that you have to hard-copy the whole QByteArray and that it will not work with your subclass-method (at least I cannot see how ).
To copy the QScriptValue back to the QByteArray, try something like this:
uint len = array.property("length").toUInt32();
byteArray.resize(len);
for (uint i = 0; i < len; ++i)
byteArray[i] = values.property(i).toInt32());
QByteArray byteArray;
uint len = array.property("length").toUInt32();
byteArray.resize(len);
for (uint i = 0; i < len; ++i)
byteArray[i] = values.property(i).toInt32());
To copy to clipboard, switch view to plain text mode
I hope this helps, lucky coding
Bookmarks