0

I used to think that, when you import a JS resource from QML, this JS file can contain only standard JS code. Then I came across 2 exceptions:

  • the .import statement
  • the property keyword (in JS), which seems to be only used in code-behind files and apparently adds a property to the QML component that imports the JS

What other "extensions" are there in JS when imported from QML, as compared with standard JS?

And I'd like these two, as well as any other extensions to the JS language, described in full. For example, what's the difference between declaring a global JS variable with and without the property keyword?

Stefan Monov
  • 11,332
  • 10
  • 63
  • 120
  • I think that the `property` keyword was a typo on behalf of whoever wrote that documentation; perhaps they were still thinking in terms of QML when they wrote it. :) At least I've never seen that syntax used in a JavaScript file used by QML before. https://bugreports.qt.io/browse/QTBUG-56008 – Mitch Sep 14 '16 at 19:20
  • I'm guessing you're just interested in syntax extensions, but just in case, there's also another kind of extension: http://doc.qt.io/qt-5/qjsengine.html#installExtensions – Mitch Sep 14 '16 at 19:22
  • @Mitch: a typo indeed. Those Qt documentation writers should either get someone to proofread their stuff or at least try running their code before posting it :D And though I *am* interested in syntax extensions, those other ones you posted are good to know, too. – Stefan Monov Sep 15 '16 at 17:07

0 Answers0