c++qtqtscript

Can I add a new value to a QObjectList from QtScript?


The function qScriptValueFromSequence allows me to create an array in QtScript from a QObjectList, where the QObject properties change when I modify them in script. If a user adds a new object to the array in the script, I would like to add a new QObject to the corresponding QObjectList, setting its properties from the properties the user has specified in the script object. However, when I've tried adding a new value to the end of the array in the script, the size of the QObjectList remains the same. Is there a way I can get this behavior to occur automatically, or will I have to manually check over the QScriptValue for the array and add new elements to the QObjectList accordingly?


Solution

  • You'd have to manually emit a signal when doing the update. You could use that signal to update your list.

    There might be some useful clues here