Scope hierarchy not working
See original GitHub issueI am wondering how to make hierarchical scoping work (it doesn’t seem to), and if it doesn’t whether a patch to implement it would be welcome. For example, in Qt QML I should be able to write something like:
Item {
property color defaultColor: "blue";
anchors.fill: context;
ListView {
model: ListModel {
ListElement { value: "foo"; }
ListElement { value: "bar"; }
ListElement { value: "baz"; }
}
anchors.fill: parent;
delegate: Rectangle {
color: defaultColor;
width: 100;
height: 100;
}
}
}
and have defaultColor picked up from the outer scope. In pureqml this builds fine but then I get a runtime error of “invalid property requested defaultColor” (shown below). It works if I qualify the reference as parent.parent.defaultColor
.
Thanks!
qml.app.js:1959 Context: initializing...
qml.app.js:5688 Context: window size: 394x656
qml.app.js:2003 Context: created instance
(index):42 Live reload enabled.
qml.app.js:1963 Context: signalling layout
qml.app.js:1966 Context: calling completed()
qml.app.js:1908 async action failed: Error: invalid property requested: 'defaultColor'
at $core.Rectangle._globals.core.core.CoreObjectComponentPrototype._get (qml.app.js:440)
at qml.app.js:2242
at PropertyStorage._globals.core.core.PropertyStoragePrototype.replaceUpdater (qml.app.js:636)
at $core.Rectangle.ObjectPrototype._replaceUpdater (qml.app.js:1382)
at $core.ListView.<anonymous> (qml.app.js:2242)
at $core.ListView.BaseViewPrototype._createDelegate (qml.app.js:3080)
at $core.ListView.ListViewPrototype._createDelegate (qml.app.js:3439)
at $core.ListView.ListViewPrototype._layout (qml.app.js:3552)
at $core.ListView.BaseLayoutPrototype._doLayout (qml.app.js:2622)
at $core.Context.callback (qml.app.js:2039) Error: invalid property requested: 'defaultColor'
at $core.Rectangle._globals.core.core.CoreObjectComponentPrototype._get (http://172.22.162.66:8080/qml.app.js:440:9)
at http://172.22.162.66:8080/qml.app.js:2242:78
at PropertyStorage._globals.core.core.PropertyStoragePrototype.replaceUpdater (http://172.22.162.66:8080/qml.app.js:636:2)
at $core.Rectangle.ObjectPrototype._replaceUpdater (http://172.22.162.66:8080/qml.app.js:1382:37)
at $core.ListView.<anonymous> (http://172.22.162.66:8080/qml.app.js:2242:13)
at $core.ListView.BaseViewPrototype._createDelegate (http://172.22.162.66:8080/qml.app.js:3080:15)
at $core.ListView.ListViewPrototype._createDelegate (http://172.22.162.66:8080/qml.app.js:3439:55)
at $core.ListView.ListViewPrototype._layout (http://172.22.162.66:8080/qml.app.js:3552:18)
at $core.ListView.BaseLayoutPrototype._doLayout (http://172.22.162.66:8080/qml.app.js:2622:8)
at $core.Context.callback (http://172.22.162.66:8080/qml.app.js:2039:11)
qml.app.js:1908 async action failed: Error: invalid property requested: 'defaultColor'
at $core.Rectangle._globals.core.core.CoreObjectComponentPrototype._get (qml.app.js:440)
at qml.app.js:2242
at PropertyStorage._globals.core.core.PropertyStoragePrototype.replaceUpdater (qml.app.js:636)
at $core.Rectangle.ObjectPrototype._replaceUpdater (qml.app.js:1382)
at $core.ListView.<anonymous> (qml.app.js:2242)
at $core.ListView.BaseViewPrototype._createDelegate (qml.app.js:3080)
at $core.ListView.ListViewPrototype._createDelegate (qml.app.js:3439)
at $core.ListView.ListViewPrototype._layout (qml.app.js:3552)
at $core.ListView.BaseLayoutPrototype._doLayout (qml.app.js:2622)
at $core.Context.callback (qml.app.js:2039) Error: invalid property requested: 'defaultColor'
at $core.Rectangle._globals.core.core.CoreObjectComponentPrototype._get (http://172.22.162.66:8080/qml.app.js:440:9)
at http://172.22.162.66:8080/qml.app.js:2242:78
at PropertyStorage._globals.core.core.PropertyStoragePrototype.replaceUpdater (http://172.22.162.66:8080/qml.app.js:636:2)
at $core.Rectangle.ObjectPrototype._replaceUpdater (http://172.22.162.66:8080/qml.app.js:1382:37)
at $core.ListView.<anonymous> (http://172.22.162.66:8080/qml.app.js:2242:13)
at $core.ListView.BaseViewPrototype._createDelegate (http://172.22.162.66:8080/qml.app.js:3080:15)
at $core.ListView.ListViewPrototype._createDelegate (http://172.22.162.66:8080/qml.app.js:3439:55)
at $core.ListView.ListViewPrototype._layout (http://172.22.162.66:8080/qml.app.js:3552:18)
at $core.ListView.BaseLayoutPrototype._doLayout (http://172.22.162.66:8080/qml.app.js:2622:8)
at $core.Context.callback (http://172.22.162.66:8080/qml.app.js:2039:11)
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Type Hierarchy scope doesn't work - always shows all subtypes
Type Hierarchy scope doesn't work - always shows all subtypes. 1. To reproduce: ... the tool window shows Foo, Bar and Baz whatever...
Read more >Scope and hierarchy - Adobe Support
Scope is an important part of Substance 3D Modeler. Learn more about what scope is and how to change your scope.
Read more >Problems with mdx scope in multiple hierarchy - MSDN
I have a problem with scope function. I'm trying to do something similar at time calculations intelligence, but not based on members that ......
Read more >AngularJS How: Scope hierarchy for Directive - Stack Overflow
Directive in AngularJS: I find out that the elements inside an element with the directive do not inherit its "scope". For example: app...
Read more >ISINSCOPE hierarchy level - Microsoft Power BI Community
I have tried to get the desired structure via isinscope. However, I do not manage to get the corresponding value.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
maybe rename it to something more readable then, like
lookup_parent
or something like thatSuper, will submit a pull request shortly with parent renamed. I meant hier, as shortening of hierarchical.