summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-11-27 16:03:41 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-07 16:23:31 +0000
commit391dc40bd25133c9b7fdd9822a013fae2683d8a6 (patch)
treebb25010f7316d6ac8e8238ba1e488e1c80b407b4 /src/corelib/kernel
parent0566e66e887f230cec2632a8129246511d12b267 (diff)
Make the signal argument in Q_OBJECT_BINDABLE_PROPERTY optional
The intention was always that you can define properties that do not require a changed signal. But having to explicitly pass a nullptr as signal parameter into the macro is ugly, so use the cool QT_OVERLOADED_MACRO to make it optional. Change-Id: I0ce366d043850f983c968d73c544d89933c48df9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit cb39ea05810bc207100018589da658a0cce98edb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qproperty.cpp3
-rw-r--r--src/corelib/kernel/qproperty.h14
2 files changed, 15 insertions, 2 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp
index e9256c7b42..27e2de7c4f 100644
--- a/src/corelib/kernel/qproperty.cpp
+++ b/src/corelib/kernel/qproperty.cpp
@@ -952,6 +952,9 @@ QString QPropertyBindingError::description() const
Q_OBJECT_BINDABLE_PROPERTY(MyClass, int, xProp, &MyClass::xChanged)
};
\endcode
+
+ If the property does not need a changed notification, you can leave out the "NOFITY xChanged" in the Q_PROPERTY macro as well as the last argument
+ of the Q_OBJECT_BINDABLE_PROPERTY macro.
*/
/*!
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h
index a533f424e8..b6653c0411 100644
--- a/src/corelib/kernel/qproperty.h
+++ b/src/corelib/kernel/qproperty.h
@@ -1013,13 +1013,23 @@ private:
}
};
-#define Q_OBJECT_BINDABLE_PROPERTY(Class, Type, name, ...) \
+#define Q_OBJECT_BINDABLE_PROPERTY3(Class, Type, name) \
static constexpr size_t _qt_property_##name##_offset() { \
QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
return offsetof(Class, name); \
QT_WARNING_POP \
} \
- QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, __VA_ARGS__> name;
+ QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, nullptr> name;
+
+#define Q_OBJECT_BINDABLE_PROPERTY4(Class, Type, name, Signal) \
+ static constexpr size_t _qt_property_##name##_offset() { \
+ QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
+ return offsetof(Class, name); \
+ QT_WARNING_POP \
+ } \
+ QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, Signal> name;
+
+#define Q_OBJECT_BINDABLE_PROPERTY(...) QT_OVERLOADED_MACRO(Q_OBJECT_BINDABLE_PROPERTY, __VA_ARGS__)
template<typename Class, typename T, auto Offset, auto Getter>
class QObjectComputedProperty : public QUntypedPropertyData