Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
6.0.0
-
None
Description
I'm trying to fix this qmllint warning:
Warning: Property "radius" not found on type "QQuickItem" at src/imports/controls/material/BoxShadow.qml:69:50 cornerRadius: blurRadius + (source && source.radius || 0) ^^^^^^
At first I was tempted to just change the type of the source property from Item to Rectangle, since it seems to be only used by it, but since the radius is optional, I figured I would try to fix it "properly":
mitch@mitch-ubuntu-18:~/dev/qt-dev/qtquickcontrols2$ git diff -- src/imports/controls/material/BoxShadow.qml diff --git a/src/imports/controls/material/BoxShadow.qml b/src/imports/controls/material/BoxShadow.qml index 5a746c0f..7bf13843 100644 --- a/src/imports/controls/material/BoxShadow.qml +++ b/src/imports/controls/material/BoxShadow.qml @@ -52,6 +52,7 @@ RectangularGlow { // The source item the shadow is being applied to, used for correctly // calculating the corner radious property Item source + readonly property real sourceRadius: source && source.hasOwnProperty("source") ? source.radius : 0 property bool fullWidth property bool fullHeight @@ -66,5 +67,5 @@ RectangularGlow { height: implicitHeight + 2 * spreadRadius + (fullHeight ? 2 * cornerRadius : 0) glowRadius: blurRadius/2 spread: 0.05 - cornerRadius: blurRadius + (source && source.radius || 0) + cornerRadius: blurRadius + sourceRadius }
mitch@mitch-ubuntu-18:~/dev/qt-dev/qtquickcontrols2$ ~/dev/qt-dev-debug/qtbase/bin/qmllint src/imports/controls/material/BoxShadow.qml Warning: Property "hasOwnProperty" not found on type "QQuickItem" at src/imports/controls/material/BoxShadow.qml:55:59 readonly property real sourceRadius: source && source.hasOwnProperty("source") ? source.radius : 0 ^^^^^^^^^^^^^^ Warning: Property "radius" not found on type "QQuickItem" at src/imports/controls/material/BoxShadow.qml:55:93 readonly property real sourceRadius: source && source.hasOwnProperty("source") ? source.radius : 0 ^^^^^^
It not knowing what hasOwnProperty() is looks like a bug, and I also don't think it should complain about radius not being found on QQuickItem if I only access it if hasOwnProperty() returns true.
Doing it this way results in no warning, but somehow feels a bit hacky:
mitch@mitch-ubuntu-18:~/dev/qt-dev/qtquickcontrols2$ git diff -- src/imports/controls/material/BoxShadow.qml
diff --git a/src/imports/controls/material/BoxShadow.qml b/src/imports/controls/material/BoxShadow.qml
index 5a746c0f..30ff6b78 100644
--- a/src/imports/controls/material/BoxShadow.qml
+++ b/src/imports/controls/material/BoxShadow.qml
@@ -66,5 +66,5 @@ RectangularGlow {
height: implicitHeight + 2 * spreadRadius + (fullHeight ? 2 * cornerRadius : 0)
glowRadius: blurRadius/2
spread: 0.05
- cornerRadius: blurRadius + (source && source.radius || 0)
+ cornerRadius: blurRadius + (source && source["radius"] || 0)
}
Attachments
Issue Links
- resulted from
-
QTBUG-83755 Fix qmllint warnings
-
- Open
-