diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-04-02 15:44:01 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-04-04 14:39:31 +0000 |
commit | a334156e81ab2491b3f65ee3c7a8269912c26a0c (patch) | |
tree | 1993f68b7363108e7d2f18772428cbee9c3b423a /src | |
parent | 90c86d738e0f36eaa48c7f81f6f5cc035a339d6b (diff) |
Add QMetaProperty::relativePropertyIndex()
Add a "sibling" function for QMetaProperty::propertyIndex() for the
relative index. That way in QtQml we can avoid using
propertyIndex() - metaObject.propertyOffset()
where the latter traverses the parent chain.
Change-Id: I113a956801b0e8d56a30a847b5b919da703824e2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 12 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobject.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index c15a9f7b0f..8309bd22c2 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -3017,6 +3017,18 @@ int QMetaProperty::propertyIndex() const } /*! + \since 5.14 + + Returns this property's index relative within the enclosing meta object. +*/ +int QMetaProperty::relativePropertyIndex() const +{ + if (!mobj) + return -1; + return idx; +} + +/*! Returns \c true if the property's type is an enumeration value that is used as a flag; otherwise returns \c false. diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 51ace3d5f7..6c5f78d208 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -253,6 +253,7 @@ public: QVariant::Type type() const; int userType() const; int propertyIndex() const; + int relativePropertyIndex() const; bool isReadable() const; bool isWritable() const; |