Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
Some future release
-
None
Description
It would be nice if QML had a dedicated type for specifying "environments" that are inherited by child items:
App.qml
Item { Environment.theme: MyTheme{} ColumnLayout { StyledButton {} StyledButton {} } }
StyledButton.qml
Item { Rectangle { color: Environment.theme.buttonBackgroundColor } ... }
This is similar to what QQuickAttachedObject allows, but without having to use private api (QTBUG-63267) and without having to use C++.
Swift has a similar feature: https://developer.apple.com/documentation/swiftui/environment
A workaround for this today is context properties, but they have many downsides.
Attachments
Issue Links
- relates to
-
QTBUG-63267 Make QQuickAttachedObject public API
- Closed