2

I want to implement a QML type in C++. Said QML type is supposed to be loaded from a Component or similar, like so:

Component {
  id: jesseMaker

  JesseType {
    id: doge
    something: "wow"
    oops: 67
    yes: "hurray"
  }
}

Notice how there's nothing unusual about this initialization. However, I also want the following JavaScript to be invalid at the denoted points:

function somewhereElse() {
  var thing = jesseMaker.createObject(this, {"something": "yay"}); // OK
  thing.oops = 12; // Should be an ERROR, as if this Q_PROPERTY had no WRITE
}

To achieve my stated goals, how can I define the relevant properties?

JesseTG
  • 2,025
  • 1
  • 24
  • 48
  • have you tried setting `oops` property to `readonly` in the `JesseType` component? subclasses can still overrite `readonly` properties but not outsiders. Just a thought! – ramtheconqueror Aug 08 '16 at 10:14
  • I guess that isn't possible. There is no difference in property visibility if that static or dynamic creation. So if a property is readonly (what you expect for) you cannot set it in the initialization time too. – folibis Aug 08 '16 at 14:28

0 Answers0