From 9be2de676aca5e2b36e2b90963a557ab42d2f2ff Mon Sep 17 00:00:00 2001 From: Stefan Dunca <47554641+stefandunca@users.noreply.github.com> Date: Mon, 4 Apr 2022 10:48:23 +0300 Subject: [PATCH] Clarify dynamic scoping --- ui/StatusQ/src/contributing.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/StatusQ/src/contributing.md b/ui/StatusQ/src/contributing.md index ed3b278b72..6950bae035 100644 --- a/ui/StatusQ/src/contributing.md +++ b/ui/StatusQ/src/contributing.md @@ -86,7 +86,7 @@ Use `Layout.preferredWidth` and `Layout.preferredHeight` attached properties to Follow [Qt's recommendations](https://doc.qt.io/qt-5/qtqml-documents-scope.html) if appropriate -- Consider dynamic scoping. Component `id`s are not accessible outside the component's scope. If required, the component can expose the instance through properties binding. E.g. `readonly property ComponentType exposedComponent: privateInstanceId` +- Avoid dynamic scoping in out-of-line components, see more: https://doc.qt.io/qt-5/qtqml-documents-scope.html#component-instance-hierarchy - Example ```qml @@ -101,6 +101,8 @@ Follow [Qt's recommendations](https://doc.qt.io/qt-5/qtqml-documents-scope.html) } ``` +- Component `id`s are not accessible outside the component's scope. If required, the component can expose the instance through properties binding. E.g. `readonly property ComponentType exposedComponent: privateInstanceId` + - If in doubt, explicitly use an instance variable to access properties - If the scope is clear and there is no ambiguity, use the property directly for readability @@ -153,4 +155,4 @@ Try scenarios - Resize window to check the behavior for each case - Visually validate that each control is behaving as expected -- Add controls with different properties that affect control size behavior \ No newline at end of file +- Add controls with different properties that affect control size behavior