Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a new javascript object in QML

Tags:

javascript

qml

I'm trying to create a new javascript object in QML.

In javascript I would simply:

var newObject = new Object();

but this is flagged as an error by QtCreator

Can anyone help?

like image 393
readysteadygo2006 Avatar asked Sep 12 '25 10:09

readysteadygo2006


1 Answers

You don't need new. You can just create an empty JS Object like this in a script part (e.g. signal handler, function etc.)

var newObject = {} // In a script.

or as a property:

property var someObject: ({}) // You need to wrap it in paranthesis

If you insist on the new-keyword

var someOtherObject = new Object // In a script

seems to be working, too.

like image 135
derM Avatar answered Sep 13 '25 23:09

derM