Details
-
Suggestion
-
Resolution: Fixed
-
P2: Important
-
None
-
403f4117e (dev), 42efc1764 (6.5), aa49d0f2d (dev), 46aaee082 (6.5)
Description
Code (Toolbar.qml) from https://doc-snapshots.qt.io/qt6-6.5/qtquickcontrols-attachedstyleproperties-example.html
// Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Templates as T import MyStyle T.ToolBar { id: control implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, contentWidth + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, contentHeight + topPadding + bottomPadding) background: Rectangle { implicitHeight: 40 // Ensure that we use Control's attached MyStyle object by qualifying // the binding with its id. If we don't do this, an extra, unnecessary // attached MyStyle object will be created for the Rectangle. color: control.MyStyle.toolBarColor } }
If we change the code to color: MyStyle.toolBarColor, then QML tooling should warn us about the unnecessary object, just like that inline comment.
Attachments
For Gerrit Dashboard: QTBUG-110834 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
458316,11 | qmllint: Fix attached property re-use detection | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
458508,9 | qmllint: Uncruftify FixSuggestion | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
459293,3 | qmllint: Uncruftify FixSuggestion | 6.5 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
460337,3 | qmllint: Fix attached property re-use detection | 6.5 | qt/qtdeclarative | Status: MERGED | +2 | 0 |