qmlcore icon indicating copy to clipboard operation
qmlcore copied to clipboard

property { } syntax

Open Benn20002 opened this issue 11 months ago • 0 comments

I have several issues/questions regarding the usage of {/} in properties. In QML by Qt I often use something like this (in a more complex way) to assign values to properties:

property int test: {
   if (a) {
      return 1;
   } else {
      return 2;
   }
}

I know this particular case is possible with something like this

property int test: a ? 1 : 2

but for more complex cases the first option is needed.

My second issue is when trying to declare a js-object like this:

property var test: {
   "a": "b"
}

it is not giving an error but when having more then one entry

property var test: {
   "a": "b",
   "c": "d"
}

I get this error: "a": "b", ^-- Expected string or identifier as object key

Am I doing anything wrong or are both cases not really implemented yet?

Benn20002 avatar Dec 26 '24 14:12 Benn20002