[Development] Copying QJSValue arrays

Paul Lemire paullemire at hotmail.com
Sun Sep 28 15:17:34 CEST 2014





Hi guys,




We're working on being able to set GLSL uniform arrays from QML.

Basically what we have is a QParameter QObject exposed to QML as Parameter.




It contains a QString name property and a QVariant value property.




Here's how it can be used for scalar types.




Parameter { name : "uniformName"; value : 1.0; } 




What we want is to send a copy of value to our backend renderer, so that we won't have any problem with threading. For scalar types, the copy is done implicitly.




For array types, we'd like to be able to do something like that:




property var myArray : [1.0, 1.0, 1.0]

Parameter { name : "uniformArray"; value : myArray }




However in that case, value is a QJSValue containing a JS Array object.

We need a way to be able to copy that object.

The tricky part there is that we can't check the QVariant to to see if it contains a QJSValue directly as we don't want to introduce a dependency to the QML module.




We're thinking of maybe introducing a Qt.array helper function that would return us a copy of the array directly or retrieve a QVector<QVariant>.




If you've got ideas around that issue, please step in.



Thanks,



Paul Lemire









 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140928/f4cc7b15/attachment.html>


More information about the Development mailing list