diff options
author | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2023-05-26 16:49:20 +0200 |
---|---|---|
committer | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2023-06-08 12:21:28 +0200 |
commit | 351979e05ad2a861fc3e6f8d1de6197a751316a8 (patch) | |
tree | 5a3c81ff5d547cf0418eebf9f10e325f260d49d8 /src/quick/handlers/qquickpointerhandler_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 <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickpointerhandler_p.h')
-rw-r--r-- | src/quick/handlers/qquickpointerhandler_p.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/quick/handlers/qquickpointerhandler_p.h b/src/quick/handlers/qquickpointerhandler_p.h index 1001718394..afc1e6d517 100644 --- a/src/quick/handlers/qquickpointerhandler_p.h +++ b/src/quick/handlers/qquickpointerhandler_p.h @@ -38,15 +38,15 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerHandler : public QObject, public QQmlP Q_OBJECT Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(bool active READ active NOTIFY activeChanged) - Q_PROPERTY(QQuickItem * target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QQuickItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged) - Q_PROPERTY(GrabPermissions grabPermissions READ grabPermissions WRITE setGrabPermissions NOTIFY grabPermissionChanged) - Q_PROPERTY(qreal margin READ margin WRITE setMargin NOTIFY marginChanged) - Q_PROPERTY(int dragThreshold READ dragThreshold WRITE setDragThreshold RESET resetDragThreshold NOTIFY dragThresholdChanged REVISION(2, 15)) + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL) + Q_PROPERTY(bool active READ active NOTIFY activeChanged FINAL) + Q_PROPERTY(QQuickItem * target READ target WRITE setTarget NOTIFY targetChanged FINAL) + Q_PROPERTY(QQuickItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged FINAL) + Q_PROPERTY(GrabPermissions grabPermissions READ grabPermissions WRITE setGrabPermissions NOTIFY grabPermissionChanged FINAL) + Q_PROPERTY(qreal margin READ margin WRITE setMargin NOTIFY marginChanged FINAL) + Q_PROPERTY(int dragThreshold READ dragThreshold WRITE setDragThreshold RESET resetDragThreshold NOTIFY dragThresholdChanged REVISION(2, 15) FINAL) #if QT_CONFIG(cursor) - Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape RESET resetCursorShape NOTIFY cursorShapeChanged REVISION(2, 15)) + Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape RESET resetCursorShape NOTIFY cursorShapeChanged REVISION(2, 15) FINAL) #endif Q_CLASSINFO("ParentProperty", "parent") |