aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickstate_p.h
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2023-05-26 16:49:20 +0200
committerOliver Eftevaag <oliver.eftevaag@qt.io>2023-06-08 12:21:28 +0200
commit351979e05ad2a861fc3e6f8d1de6197a751316a8 (patch)
tree5a3c81ff5d547cf0418eebf9f10e325f260d49d8 /src/quick/util/qquickstate_p.h
parentb80f0383ab99a92e0470800ea1b1382453a7e9aa (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 <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/util/qquickstate_p.h')
-rw-r--r--src/quick/util/qquickstate_p.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/quick/util/qquickstate_p.h b/src/quick/util/qquickstate_p.h
index 41b0a10835..da9b375cff 100644
--- a/src/quick/util/qquickstate_p.h
+++ b/src/quick/util/qquickstate_p.h
@@ -120,10 +120,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickState : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(bool when READ when WRITE setWhen)
- Q_PROPERTY(QString extend READ extends WRITE setExtends)
- Q_PROPERTY(QQmlListProperty<QQuickStateOperation> changes READ changes)
+ Q_PROPERTY(QString name READ name WRITE setName FINAL)
+ Q_PROPERTY(bool when READ when WRITE setWhen FINAL)
+ Q_PROPERTY(QString extend READ extends WRITE setExtends FINAL)
+ Q_PROPERTY(QQmlListProperty<QQuickStateOperation> changes READ changes FINAL)
Q_CLASSINFO("DefaultProperty", "changes")
Q_CLASSINFO("DeferredPropertyNames", "changes")
QML_NAMED_ELEMENT(State)