diff options
author | Oliver Eftevaag <[email protected]> | 2023-05-26 16:49:20 +0200 |
---|---|---|
committer | Oliver Eftevaag <[email protected]> | 2023-06-08 12:21:28 +0200 |
commit | 351979e05ad2a861fc3e6f8d1de6197a751316a8 (patch) | |
tree | 5a3c81ff5d547cf0418eebf9f10e325f260d49d8 /src/quick/items/qquickitemviewtransition_p.h | |
parent | b80f0383ab99a92e0470800ea1b1382453a7e9aa (diff) |
Make properties in Qt Quick FINAL to prevent shadowing
Without setting the FINAL flag, properties can be shadowed by users.
In the following example:
Image {
property string source: "Shadowing QQuickImage::source"
}
The source property of QQuickImage, will be shadowed by a new property
with the same name.
This can both cause confusion for non-experienced users, and it causes
issues with qmlsc.
Shadowing a property is usually unwanted. But there are some situations
where it might be intended. The QML Object Attributes doc page
demonstrates that you can override the color property in
QQuickRectangle, for instance.
[ChangeLog][Important Behavior Changes][QtQuick] Most properties for
types in the QtQuick module are now FINAL, meaning that they can no
longer be shadowed by declaring new properties with the same names.
With few exceptions. A warning will be printed out to the console, when
a FINAL property is shadowed. We recommend that users rename those
properties to avoid potential unexpected behavior changes.
Task-number: QTBUG-108739
Pick-to: 6.6
Change-Id: I1070926606f4d88ef7edf088ff80fb3ec82305c8
Reviewed-by: Jan Arve Sæther <[email protected]>
Diffstat (limited to 'src/quick/items/qquickitemviewtransition_p.h')
-rw-r--r-- | src/quick/items/qquickitemviewtransition_p.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h index 01e504a440..f066b80962 100644 --- a/src/quick/items/qquickitemviewtransition_p.h +++ b/src/quick/items/qquickitemviewtransition_p.h @@ -152,12 +152,12 @@ class QQuickViewTransitionAttached : public QObject { Q_OBJECT - Q_PROPERTY(int index READ index NOTIFY indexChanged) - Q_PROPERTY(QQuickItem* item READ item NOTIFY itemChanged) - Q_PROPERTY(QPointF destination READ destination NOTIFY destinationChanged) + Q_PROPERTY(int index READ index NOTIFY indexChanged FINAL) + Q_PROPERTY(QQuickItem* item READ item NOTIFY itemChanged FINAL) + Q_PROPERTY(QPointF destination READ destination NOTIFY destinationChanged FINAL) - Q_PROPERTY(QList<int> targetIndexes READ targetIndexes NOTIFY targetIndexesChanged) - Q_PROPERTY(QQmlListProperty<QObject> targetItems READ targetItems NOTIFY targetItemsChanged) + Q_PROPERTY(QList<int> targetIndexes READ targetIndexes NOTIFY targetIndexesChanged FINAL) + Q_PROPERTY(QQmlListProperty<QObject> targetItems READ targetItems NOTIFY targetItemsChanged FINAL) QML_NAMED_ELEMENT(ViewTransition) QML_ADDED_IN_VERSION(2, 0) |