[Qt-qml] Removal of the Script element
mathias.malmqvist at nokia.com
mathias.malmqvist at nokia.com
Thu Mar 25 18:24:40 CET 2010
Hi guys,
Has the removal of the Script element in Qt 4.7 also removed the
possibility to scope the imported scrips?
Previously, adding importing a script file like this
Item {
id: myRoot
Script { source: "foo.js" }
[...]
}
made everything defined in foo.js available to all child elements of myRoot,
event component ones defined in other qml files.
Changing this to the new syntax:
import "foo.js" as Foo
Item {
id: myRoot
[...]
}
makes the definitions in foo.js available as e.g. Foo.bar(), but only to
elements defined in the same file as myRoot.
Now of course one could add
import "foo.js" as Foo
to all files that need access to its definitions. The problem is it appears
anything in foo.js will be re-instantiated every time it's imported (actually
it seems every time a component defined in the file that imports the js-file
is instantiated).
Am I missing something? Is thee a way to still import the definitions in a script
file as singletons available to the whole QML application?
Cheers
Mathias
------------------------------------------------------------
Mathias Malmqvist
CWRT Prototype Lead
S SE UX Prototyping GB
10 Great Pulteney Street, London, W1F 9NB, UK
Got no reply? Try giving me a call:
Mobile: +44 (0)77 6522 2738
http://www.nokia.com
More information about the Qt-qml
mailing list