Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
Description
Code
import QtQuick Window { id: window width: 640 height: 480 visible: true component Config: QtObject { required property color winColor } component BadConfig: Config { property color winColor: "beige" } property Config cfg: BadConfig { winColor: "yellow" } color: window.cfg.winColor }
Outcomes
At compile time, qmlsc says,
Warning: Main.qml:13:20: Member winColor of QObject of (component in Main.qml)::cfg with type Config can be shadowed [compiler] color: window.cfg.winColor ^^^^^^^^
And indeed, BadConfig is trying to shadow it. However, it cannot do that because we get this at runtime:
QQmlApplicationEngine failed to create component qrc:/qt/qml/untitled4/Main.qml:9:31: Required property winColor was not initialized
Suggestion
Since it is impossible to shadow a required property without blocking the object's initialization, could we treat that property as FINAL?
- (Primary suggestion) qmlsc shouldn't warn that Config.winColor can be shadowed
- (Secondary suggestion) BadConfig trying to implement a new property called winColor should be treated as an error
Attachments
Issue Links
- relates to
-
QTBUG-98320 Clean up overriding of Q_PROPERTY and Q_INVOKABLE
-
- Reported
-
-
QTBUG-96588 Allow "final" modifier on QML properties
-
- Closed
-