Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qproperty.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPROPERTY_H
5#define QPROPERTY_H
6
7#include <QtCore/qglobal.h>
8#include <QtCore/qshareddata.h>
9#include <QtCore/qstring.h>
10#include <QtCore/qbindingstorage.h>
11
12#include <type_traits>
13
14#include <QtCore/qpropertyprivate.h>
15
16#if __has_include(<source_location>) && __cplusplus >= 202002L && !defined(Q_QDOC)
17#include <source_location>
18#if defined(__cpp_lib_source_location)
19#define QT_SOURCE_LOCATION_NAMESPACE std
20#define QT_PROPERTY_COLLECT_BINDING_LOCATION
21#if defined(Q_CC_MSVC)
22/* MSVC runs into an issue with constexpr with source location (error C7595)
23 so use the factory function as a workaround */
24# define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation::fromStdSourceLocation(std::source_location::current())
25#else
26/* some versions of gcc in turn run into
27 expression ‘std::source_location::current()’ is not a constant expression
28 so don't use the workaround there */
29# define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation(std::source_location::current())
30#endif
31#endif
32#endif
33
34#if __has_include(<experimental/source_location>) && !defined(Q_QDOC)
35#include <experimental/source_location>
36#if !defined(QT_PROPERTY_COLLECT_BINDING_LOCATION)
37#if defined(__cpp_lib_experimental_source_location)
38#define QT_SOURCE_LOCATION_NAMESPACE std::experimental
39#define QT_PROPERTY_COLLECT_BINDING_LOCATION
40#define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation(std::experimental::source_location::current())
41#endif // defined(__cpp_lib_experimental_source_location)
42#endif
43#endif
44
45#if !defined(QT_PROPERTY_COLLECT_BINDING_LOCATION)
46#define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation()
47#endif
48
50
51namespace Qt {
52Q_CORE_EXPORT void beginPropertyUpdateGroup();
53Q_CORE_EXPORT void endPropertyUpdateGroup();
54}
55
57{
58 Q_DISABLE_COPY_MOVE(QScopedPropertyUpdateGroup)
59public:
65};
66
67template <typename T>
69{
70protected:
71 mutable T val = T();
72private:
73 class DisableRValueRefs {};
74protected:
75 static constexpr bool UseReferences = !(std::is_arithmetic_v<T> || std::is_enum_v<T> || std::is_pointer_v<T>);
76public:
77 using value_type = T;
78 using parameter_type = std::conditional_t<UseReferences, const T &, T>;
79 using rvalue_ref = typename std::conditional_t<UseReferences, T &&, DisableRValueRefs>;
80 using arrow_operator_result = std::conditional_t<std::is_pointer_v<T>, const T &,
81 std::conditional_t<QTypeTraits::is_dereferenceable_v<T>, const T &, void>>;
82
83 QPropertyData() = default;
86 ~QPropertyData() = default;
87
90 void setValueBypassingBindings(rvalue_ref v) { val = std::move(v); }
91};
92
93// ### Qt 7: un-export
95{
96 const char *fileName = nullptr;
97 const char *functionName = nullptr;
101#ifdef __cpp_lib_source_location
102 constexpr QPropertyBindingSourceLocation(const std::source_location &cppLocation)
103 {
104 fileName = cppLocation.file_name();
105 functionName = cppLocation.function_name();
106 line = cppLocation.line();
107 column = cppLocation.column();
108 }
110 static consteval QPropertyBindingSourceLocation
111 fromStdSourceLocation(const std::source_location &cppLocation)
112 {
113 return cppLocation;
114 }
115#endif
116#ifdef __cpp_lib_experimental_source_location
117 constexpr QPropertyBindingSourceLocation(const std::experimental::source_location &cppLocation)
118 {
119 fileName = cppLocation.file_name();
120 functionName = cppLocation.function_name();
121 line = cppLocation.line();
122 column = cppLocation.column();
123 }
124#endif
125};
126
127template <typename Functor> class QPropertyChangeHandler;
129
130class Q_CORE_EXPORT QPropertyBindingError
131{
132public:
133 enum Type {
137 UnknownError
138 };
139
141 QPropertyBindingError(Type type, const QString &description = QString());
142
148
149 bool hasError() const { return d.get() != nullptr; }
150 Type type() const;
151 QString description() const;
152
153private:
155};
156
157class Q_CORE_EXPORT QUntypedPropertyBinding
158{
159public:
160 // writes binding result into dataPtr
162
165
166 template<typename Functor>
168 : QUntypedPropertyBinding(metaType, &QtPrivate::bindingFunctionVTable<std::remove_reference_t<Functor>>, &f, location)
169 {}
170
176
177 bool isNull() const;
178
180
181 QMetaType valueMetaType() const;
182
184private:
187 template <typename> friend class QPropertyBinding;
189};
190
191template <typename PropertyType>
193{
194
195public:
196 QPropertyBinding() = default;
197
198 template<typename Functor>
200 : QUntypedPropertyBinding(QMetaType::fromType<PropertyType>(), &QtPrivate::bindingFunctionVTable<std::remove_reference_t<Functor>, PropertyType>, &f, location)
201 {}
202
203
204 // Internal
206 : QUntypedPropertyBinding(binding)
207 {}
208};
209
210namespace Qt {
211 template <typename Functor>
213 std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
214 {
215 return QPropertyBinding<std::invoke_result_t<Functor>>(std::forward<Functor>(f), location);
216 }
217}
218
219struct QPropertyObserverPrivate;
222
224{
225public:
226 // Internal
228 ObserverNotifiesBinding, // observer was installed to notify bindings that obsverved property changed
229 ObserverNotifiesChangeHandler, // observer is a change handler, which runs on every change
230 ObserverIsPlaceholder, // the observer before this one is currently evaluated in QPropertyObserver::notifyObservers.
231#if QT_DEPRECATED_SINCE(6, 6)
232 ObserverIsAlias
233#endif
234 };
235protected:
237
238private:
241 friend class QPropertyObserver;
245
247 // prev is a pointer to the "next" element within the previous node, or to the "firstObserverPtr" if it is the
248 // first node.
250
251 union {
255 };
256};
257
258class Q_CORE_EXPORT QPropertyObserver : public QPropertyObserverBase
259{
260public:
261 constexpr QPropertyObserver() = default;
263 QPropertyObserver &operator=(QPropertyObserver &&other) noexcept;
265
266 template<typename Property, typename = typename Property::InheritsQUntypedPropertyData>
267 void setSource(const Property &property)
268 { setSource(property.bindingData()); }
269 void setSource(const QtPrivate::QPropertyBindingData &property);
270
271protected:
272 QPropertyObserver(ChangeHandler changeHandler);
273#if QT_DEPRECATED_SINCE(6, 6)
275#endif
276
278 {
279 return aliasData;
280 }
281
282private:
283
284 QPropertyObserver(const QPropertyObserver &) = delete;
285 QPropertyObserver &operator=(const QPropertyObserver &) = delete;
286
287};
288
289template <typename Functor>
291{
292 Functor m_handler;
293public:
297 auto This = static_cast<QPropertyChangeHandler<Functor>*>(self);
298 This->m_handler();
299 })
300 , m_handler(handler)
301 {
302 }
303
304 template<typename Property, typename = typename Property::InheritsQUntypedPropertyData>
306 QPropertyChangeHandler(const Property &property, Functor handler)
308 auto This = static_cast<QPropertyChangeHandler<Functor>*>(self);
309 This->m_handler();
310 })
311 , m_handler(handler)
312 {
314 }
315};
316
318{
319 std::function<void()> m_handler;
320public:
322 QPropertyNotifier() = default;
323 template<typename Functor>
327 auto This = static_cast<QPropertyNotifier *>(self);
328 This->m_handler();
329 })
330 , m_handler(handler)
331 {
332 }
333
334 template<typename Functor, typename Property, typename = typename Property::InheritsQUntypedPropertyData>
336 QPropertyNotifier(const Property &property, Functor handler)
338 auto This = static_cast<QPropertyNotifier *>(self);
339 This->m_handler();
340 })
341 , m_handler(handler)
342 {
344 }
345};
346
347template <typename T>
348class QProperty : public QPropertyData<T>
349{
351 bool is_equal(const T &v)
352 {
353 if constexpr (QTypeTraits::has_operator_equal_v<T>) {
354 if (v == this->val)
355 return true;
356 }
357 return false;
358 }
359
360public:
365
366 QProperty() = default;
367 explicit QProperty(parameter_type initialValue) : QPropertyData<T>(initialValue) {}
368 explicit QProperty(rvalue_ref initialValue) : QPropertyData<T>(std::move(initialValue)) {}
370 : QProperty()
371 { setBinding(binding); }
372#ifndef Q_QDOC
373 template <typename Functor>
375 typename std::enable_if_t<std::is_invocable_r_v<T, Functor&>> * = nullptr)
377 {}
378#else
379 template <typename Functor>
380 explicit QProperty(Functor &&f);
381#endif
382 ~QProperty() = default;
383
385 {
386 d.registerWithCurrentlyEvaluatingBinding();
387 return this->val;
388 }
389
391 {
392 if constexpr (QTypeTraits::is_dereferenceable_v<T>) {
393 return value();
394 } else if constexpr (std::is_pointer_v<T>) {
395 value();
396 return this->val;
397 } else {
398 return;
399 }
400 }
401
403 {
404 return value();
405 }
406
407 operator parameter_type() const
408 {
409 return value();
410 }
411
412 void setValue(rvalue_ref newValue)
413 {
414 d.removeBinding();
415 if (is_equal(newValue))
416 return;
417 this->val = std::move(newValue);
418 notify();
419 }
420
422 {
423 d.removeBinding();
424 if (is_equal(newValue))
425 return;
426 this->val = newValue;
427 notify();
428 }
429
431 {
432 setValue(std::move(newValue));
433 return *this;
434 }
435
437 {
438 setValue(newValue);
439 return *this;
440 }
441
443 {
444 return QPropertyBinding<T>(d.setBinding(newBinding, this));
445 }
446
447 bool setBinding(const QUntypedPropertyBinding &newBinding)
448 {
449 if (!newBinding.isNull() && newBinding.valueMetaType().id() != qMetaTypeId<T>())
450 return false;
451 setBinding(static_cast<const QPropertyBinding<T> &>(newBinding));
452 return true;
453 }
454
455#ifndef Q_QDOC
456 template <typename Functor>
459 std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
460 {
461 return setBinding(Qt::makePropertyBinding(std::forward<Functor>(f), location));
462 }
463#else
464 template <typename Functor>
466#endif
467
468 bool hasBinding() const { return d.hasBinding(); }
469
471 {
473 }
474
476 {
477 return QPropertyBinding<T>(d.setBinding(QUntypedPropertyBinding(), this));
478 }
479
480 template<typename Functor>
482 {
483 static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
484 return QPropertyChangeHandler<Functor>(*this, f);
485 }
486
487 template<typename Functor>
489 {
490 static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
491 f();
492 return onValueChanged(f);
493 }
494
495 template<typename Functor>
497 {
498 static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
499 return QPropertyNotifier(*this, f);
500 }
501
503private:
504 void notify()
505 {
506 d.notifyObservers(this);
507 }
508
509 Q_DISABLE_COPY_MOVE(QProperty)
510};
511
512namespace Qt {
513 template <typename PropertyType>
517 {
518 return Qt::makePropertyBinding([&otherProperty]() -> PropertyType { return otherProperty; }, location);
519 }
520}
521
522
523namespace QtPrivate
524{
525
527{
528 using Getter = void (*)(const QUntypedPropertyData *d, void *value);
529 using Setter = void (*)(QUntypedPropertyData *d, const void *value);
534 using GetMetaType = QMetaType (*)();
542
543 static constexpr quintptr MetaTypeAccessorFlag = 0x1;
544};
545
546template<typename Property, typename = void>
548{
549 using T = typename Property::value_type;
550public:
551 // interface for computed properties. Those do not have a binding()/setBinding() method, but one can
552 // install observers on them.
553 static constexpr QBindableInterface iface = {
554 [](const QUntypedPropertyData *d, void *value) -> void
555 { *static_cast<T*>(value) = static_cast<const Property *>(d)->value(); },
556 nullptr,
557 nullptr,
558 nullptr,
560 { return Qt::makePropertyBinding([d]() -> T { return static_cast<const Property *>(d)->value(); }, location); },
561 [](const QUntypedPropertyData *d, QPropertyObserver *observer) -> void
562 { observer->setSource(static_cast<const Property *>(d)->bindingData()); },
563 []() { return QMetaType::fromType<T>(); }
564 };
565};
566
567template<typename Property>
568class QBindableInterfaceForProperty<const Property, std::void_t<decltype(std::declval<Property>().binding())>>
569{
570 using T = typename Property::value_type;
571public:
572 // A bindable created from a const property results in a read-only interface, too.
573 static constexpr QBindableInterface iface = {
574
575 [](const QUntypedPropertyData *d, void *value) -> void
576 { *static_cast<T*>(value) = static_cast<const Property *>(d)->value(); },
577 /*setter=*/nullptr,
579 { return static_cast<const Property *>(d)->binding(); },
580 /*setBinding=*/nullptr,
582 { return Qt::makePropertyBinding([d]() -> T { return static_cast<const Property *>(d)->value(); }, location); },
583 [](const QUntypedPropertyData *d, QPropertyObserver *observer) -> void
584 { observer->setSource(static_cast<const Property *>(d)->bindingData()); },
585 []() { return QMetaType::fromType<T>(); }
586 };
587};
588
589template<typename Property>
590class QBindableInterfaceForProperty<Property, std::void_t<decltype(std::declval<Property>().binding())>>
591{
592 using T = typename Property::value_type;
593public:
594 static constexpr QBindableInterface iface = {
595 [](const QUntypedPropertyData *d, void *value) -> void
596 { *static_cast<T*>(value) = static_cast<const Property *>(d)->value(); },
597 [](QUntypedPropertyData *d, const void *value) -> void
598 { static_cast<Property *>(d)->setValue(*static_cast<const T*>(value)); },
600 { return static_cast<const Property *>(d)->binding(); },
602 { return static_cast<Property *>(d)->setBinding(static_cast<const QPropertyBinding<T> &>(binding)); },
604 { return Qt::makePropertyBinding([d]() -> T { return static_cast<const Property *>(d)->value(); }, location); },
605 [](const QUntypedPropertyData *d, QPropertyObserver *observer) -> void
606 { observer->setSource(static_cast<const Property *>(d)->bindingData()); },
607 []() { return QMetaType::fromType<T>(); }
608 };
609};
610
611}
612
613namespace QtPrivate {
614// used in Q(Untyped)Bindable to print warnings about various binding errors
615namespace BindableWarnings {
617Q_CORE_EXPORT void printUnsuitableBindableWarning(QAnyStringView prefix, Reason reason);
618Q_CORE_EXPORT void printMetaTypeMismatch(QMetaType actual, QMetaType expected);
619}
620
621namespace PropertyAdaptorSlotObjectHelpers {
622Q_CORE_EXPORT void getter(const QUntypedPropertyData *d, void *value);
623Q_CORE_EXPORT void setter(QUntypedPropertyData *d, const void *value);
627 QUntypedPropertyData *temp, void *value);
629 const QUntypedPropertyBinding &binding,
631Q_CORE_EXPORT void setObserver(const QUntypedPropertyData *d, QPropertyObserver *observer);
632
633template<typename T>
636{
637 struct Data : QPropertyData<T>
638 {
639 void *data() { return &this->val; }
640 } temp;
641 return bindingWrapper(type, d, binding, &temp, temp.data());
642}
643
644template<typename T>
646{
647 return setBinding(d, binding, &bindingWrapper<T>);
648}
649
650template<typename T>
653{
655 [d]() -> T {
656 T r;
657 getter(d, &r);
658 return r;
659 },
660 location);
661}
662
663template<class T>
664inline constexpr QBindableInterface iface = {
665 &getter,
666 &setter,
667 &getBinding,
668 &setBinding<T>,
669 &makeBinding<T>,
671 &QMetaType::fromType<T>,
672};
673}
674}
675
677{
678 friend struct QUntypedBindablePrivate; // allows access to internal data
679protected:
683 : data(d), iface(i)
684 {}
685
686 Q_CORE_EXPORT explicit QUntypedBindable(QObject* obj, const QMetaProperty &property, const QtPrivate::QBindableInterface *i);
687 Q_CORE_EXPORT explicit QUntypedBindable(QObject* obj, const char* property, const QtPrivate::QBindableInterface *i);
688
689public:
690 constexpr QUntypedBindable() = default;
691 template<typename Property>
693 : data(const_cast<std::remove_cv_t<Property> *>(p)),
694 iface(&QtPrivate::QBindableInterfaceForProperty<Property>::iface)
695 { Q_ASSERT(data && iface); }
696
697 bool isValid() const { return data != nullptr; }
698 bool isBindable() const { return iface && iface->getBinding; }
699 bool isReadOnly() const { return !(iface && iface->setBinding && iface->setObserver); }
700
702 {
704 }
705
707 {
708 if (!iface)
709 return QUntypedPropertyBinding {};
710 // We do not have a dedicated takeBinding function pointer in the interface
711 // therefore we synthesize takeBinding by retrieving the binding with binding
712 // and calling setBinding with a default constructed QUntypedPropertyBinding
713 // afterwards.
714 if (!(iface->getBinding && iface->setBinding))
715 return QUntypedPropertyBinding {};
718 return binding;
719 }
720
721 void observe(QPropertyObserver *observer) const
722 {
723 if (iface)
724 iface->setObserver(data, observer);
725#ifndef QT_NO_DEBUG
726 else
729#endif
730 }
731
732 template<typename Functor>
734 {
736 observe(&handler);
737 return handler;
738 }
739
740 template<typename Functor>
742 {
743 f();
744 return onValueChanged(f);
745 }
746
747 template<typename Functor>
749 {
750 QPropertyNotifier handler(f);
751 observe(&handler);
752 return handler;
753 }
754
756 {
757 if (!isBindable()) {
758#ifndef QT_NO_DEBUG
761#endif
763 }
764 return iface->getBinding(data);
765 }
767 {
768 if (isReadOnly()) {
769#ifndef QT_NO_DEBUG
772 QtPrivate::BindableWarnings::printUnsuitableBindableWarning("setBinding: Could not set binding via bindable interface.", errorType);
773#endif
774 return false;
775 }
776 if (!binding.isNull() && binding.valueMetaType() != metaType()) {
777#ifndef QT_NO_DEBUG
779#endif
780 return false;
781 }
783 return true;
784 }
785 bool hasBinding() const
786 {
787 return !binding().isNull();
788 }
789
791 {
792 if (!(iface && data))
793 return QMetaType();
794 if (iface->metaType)
795 return iface->metaType();
796 // ### Qt 7: Change the metatype function to take data as its argument
797 // special casing for QML's proxy bindable: allow multiplexing in the getter
798 // function to retrieve the metatype from data
802 return result;
803 }
804
805};
806
807template<typename T>
809{
810 template<typename U>
811 friend class QPropertyAlias;
814 {}
815public:
818 {
819 if (iface && metaType() != QMetaType::fromType<T>()) {
820 data = nullptr;
821 iface = nullptr;
822 }
823 }
824
826 : QUntypedBindable(obj, property, &QtPrivate::PropertyAdaptorSlotObjectHelpers::iface<T>) {}
827
828 explicit QBindable(QObject *obj, const char *property)
829 : QUntypedBindable(obj, property, &QtPrivate::PropertyAdaptorSlotObjectHelpers::iface<T>) {}
830
832 {
834 }
836 {
837 return static_cast<QPropertyBinding<T> &&>(QUntypedBindable::binding());
838 }
839
841 {
842 return static_cast<QPropertyBinding<T> &&>(QUntypedBindable::takeBinding());
843 }
844
847 {
848 Q_ASSERT(!iface || binding.isNull() || binding.valueMetaType() == metaType());
849
850 if (iface && iface->setBinding)
851 return static_cast<QPropertyBinding<T> &&>(iface->setBinding(data, binding));
852#ifndef QT_NO_DEBUG
853 if (!iface)
855 else
857#endif
858 return QPropertyBinding<T>();
859 }
860#ifndef Q_QDOC
861 template <typename Functor>
864 std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
865 {
866 return setBinding(Qt::makePropertyBinding(std::forward<Functor>(f), location));
867 }
868#else
869 template <typename Functor>
871#endif
872
873 T value() const
874 {
875 if (iface) {
876 T result;
878 return result;
879 }
880 return T{};
881 }
882
883 void setValue(const T &value)
884 {
885 if (iface && iface->setter)
887 }
888};
889
890#if QT_DEPRECATED_SINCE(6, 6)
891template<typename T>
892class QT_DEPRECATED_X("Class was only meant for internal use, use a QProperty and add a binding to the target")
894{
895 Q_DISABLE_COPY_MOVE(QPropertyAlias)
896 const QtPrivate::QBindableInterface *iface = nullptr;
897
898public:
902 iface(&QtPrivate::QBindableInterfaceForProperty<QProperty<T>>::iface)
903 {
904 if (iface)
906 }
907
908 template<typename Property, typename = typename Property::InheritsQUntypedPropertyData>
909 QPropertyAlias(Property *property)
911 iface(&QtPrivate::QBindableInterfaceForProperty<Property>::iface)
912 {
913 if (iface)
915 }
916
918 : QPropertyObserver(alias->aliasedProperty()),
919 iface(alias->iface)
920 {
921 if (iface)
923 }
924
928 {
929 if (iface)
931 }
932
933 T value() const
934 {
935 T t = T();
936 if (auto *p = aliasedProperty())
937 iface->getter(p, &t);
938 return t;
939 }
940
941 operator T() const { return value(); }
942
943 void setValue(const T &newValue)
944 {
945 if (auto *p = aliasedProperty())
946 iface->setter(p, &newValue);
947 }
948
949 QPropertyAlias<T> &operator=(const T &newValue)
950 {
951 setValue(newValue);
952 return *this;
953 }
954
956 {
957 return QBindable<T>(aliasedProperty(), iface).setBinding(newBinding);
958 }
959
960 bool setBinding(const QUntypedPropertyBinding &newBinding)
961 {
962 return QBindable<T>(aliasedProperty(), iface).setBinding(newBinding);
963 }
964
965#ifndef Q_QDOC
966 template <typename Functor>
969 std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
970 {
971 return setBinding(Qt::makePropertyBinding(std::forward<Functor>(f), location));
972 }
973#else
974 template <typename Functor>
976#endif
977
978 bool hasBinding() const
979 {
980 return QBindable<T>(aliasedProperty(), iface).hasBinding();
981 }
982
984 {
985 return QBindable<T>(aliasedProperty(), iface).binding();
986 }
987
988 QPropertyBinding<T> takeBinding()
989 {
990 return QBindable<T>(aliasedProperty(), iface).takeBinding();
991 }
992
993 template<typename Functor>
995 {
997 }
998
999 template<typename Functor>
1001 {
1002 return QBindable<T>(aliasedProperty(), iface).subscribe(f);
1003 }
1004
1005 template<typename Functor>
1006 QPropertyNotifier addNotifier(Functor f)
1007 {
1008 return QBindable<T>(aliasedProperty(), iface).addNotifier(f);
1009 }
1010
1011 bool isValid() const
1012 {
1013 return aliasedProperty() != nullptr;
1014 }
1016};
1017#endif
1018
1019template<typename Class, typename T, auto Offset, auto Signal = nullptr>
1021{
1023 static bool constexpr HasSignal = !std::is_same_v<decltype(Signal), std::nullptr_t>;
1024 using SignalTakesValue = std::is_invocable<decltype(Signal), Class, T>;
1025 Class *owner()
1026 {
1027 char *that = reinterpret_cast<char *>(this);
1028 return reinterpret_cast<Class *>(that - QtPrivate::detail::getOffset(Offset));
1029 }
1030 const Class *owner() const
1031 {
1032 char *that = const_cast<char *>(reinterpret_cast<const char *>(this));
1033 return reinterpret_cast<Class *>(that - QtPrivate::detail::getOffset(Offset));
1034 }
1035 static void signalCallBack(QUntypedPropertyData *o)
1036 {
1037 QObjectBindableProperty *that = static_cast<QObjectBindableProperty *>(o);
1038 if constexpr (HasSignal) {
1039 if constexpr (SignalTakesValue::value)
1040 (that->owner()->*Signal)(that->valueBypassingBindings());
1041 else
1042 (that->owner()->*Signal)();
1043 }
1044 }
1045public:
1050
1052 explicit QObjectBindableProperty(const T &initialValue) : QPropertyData<T>(initialValue) {}
1053 explicit QObjectBindableProperty(T &&initialValue) : QPropertyData<T>(std::move(initialValue)) {}
1056 { setBinding(binding); }
1057#ifndef Q_QDOC
1058 template <typename Functor>
1060 typename std::enable_if_t<std::is_invocable_r_v<T, Functor&>> * = nullptr)
1062 {}
1063#else
1064 template <typename Functor>
1065 explicit QObjectBindableProperty(Functor &&f);
1066#endif
1067
1069 {
1070 qGetBindingStorage(owner())->registerDependency(this);
1071 return this->val;
1072 }
1073
1075 {
1076 if constexpr (QTypeTraits::is_dereferenceable_v<T>) {
1077 return value();
1078 } else if constexpr (std::is_pointer_v<T>) {
1079 value();
1080 return this->val;
1081 } else {
1082 return;
1083 }
1084 }
1085
1087 {
1088 return value();
1089 }
1090
1091 operator parameter_type() const
1092 {
1093 return value();
1094 }
1095
1097 {
1098 auto *bd = qGetBindingStorage(owner())->bindingData(this);
1099 if (bd)
1100 bd->removeBinding();
1101 if (this->val == t)
1102 return;
1103 this->val = t;
1104 notify(bd);
1105 }
1106
1107 void notify() {
1108 auto *bd = qGetBindingStorage(owner())->bindingData(this);
1109 notify(bd);
1110 }
1111
1113 {
1114 auto *bd = qGetBindingStorage(owner())->bindingData(this);
1115 if (bd)
1116 bd->removeBinding();
1117 if (this->val == t)
1118 return;
1119 this->val = std::move(t);
1120 notify(bd);
1121 }
1122
1124 {
1125 setValue(std::move(newValue));
1126 return *this;
1127 }
1128
1130 {
1131 setValue(newValue);
1132 return *this;
1133 }
1134
1136 {
1138 QUntypedPropertyBinding oldBinding(bd->setBinding(newBinding, this, HasSignal ? &signalCallBack : nullptr));
1139 return static_cast<QPropertyBinding<T> &>(oldBinding);
1140 }
1141
1142 bool setBinding(const QUntypedPropertyBinding &newBinding)
1143 {
1144 if (!newBinding.isNull() && newBinding.valueMetaType().id() != qMetaTypeId<T>())
1145 return false;
1146 setBinding(static_cast<const QPropertyBinding<T> &>(newBinding));
1147 return true;
1148 }
1149
1150#ifndef Q_QDOC
1151 template <typename Functor>
1154 std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
1155 {
1156 return setBinding(Qt::makePropertyBinding(std::forward<Functor>(f), location));
1157 }
1158#else
1159 template <typename Functor>
1161#endif
1162
1163 bool hasBinding() const
1164 {
1165 auto *bd = qGetBindingStorage(owner())->bindingData(this);
1166 return bd && bd->binding() != nullptr;
1167 }
1168
1170 {
1171 auto *bd = qGetBindingStorage(owner())->bindingData(this);
1172 return static_cast<QPropertyBinding<T> &&>(QUntypedPropertyBinding(bd ? bd->binding() : nullptr));
1173 }
1174
1176 {
1178 }
1179
1180 template<typename Functor>
1182 {
1183 static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1184 return QPropertyChangeHandler<Functor>(*this, f);
1185 }
1186
1187 template<typename Functor>
1189 {
1190 static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1191 f();
1192 return onValueChanged(f);
1193 }
1194
1195 template<typename Functor>
1197 {
1198 static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1199 return QPropertyNotifier(*this, f);
1200 }
1201
1203 {
1204 auto *storage = const_cast<QBindingStorage *>(qGetBindingStorage(owner()));
1205 return *storage->bindingData(const_cast<ThisType *>(this), true);
1206 }
1207private:
1209 {
1210 if (binding)
1211 binding->notifyObservers(this, qGetBindingStorage(owner()));
1212 if constexpr (HasSignal) {
1213 if constexpr (SignalTakesValue::value)
1214 (owner()->*Signal)(this->valueBypassingBindings());
1215 else
1216 (owner()->*Signal)();
1217 }
1218 }
1219};
1220
1221#define QT_OBJECT_BINDABLE_PROPERTY_3(Class, Type, name) \
1222 static constexpr size_t _qt_property_##name##_offset() { \
1223 QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1224 return offsetof(Class, name); \
1225 QT_WARNING_POP \
1226 } \
1227 QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, nullptr> name;
1228
1229#define QT_OBJECT_BINDABLE_PROPERTY_4(Class, Type, name, Signal) \
1230 static constexpr size_t _qt_property_##name##_offset() { \
1231 QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1232 return offsetof(Class, name); \
1233 QT_WARNING_POP \
1234 } \
1235 QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, Signal> name;
1236
1237#define Q_OBJECT_BINDABLE_PROPERTY(...) \
1238 QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1239 QT_OVERLOADED_MACRO(QT_OBJECT_BINDABLE_PROPERTY, __VA_ARGS__) \
1240 QT_WARNING_POP
1241
1242#define QT_OBJECT_BINDABLE_PROPERTY_WITH_ARGS_4(Class, Type, name, value) \
1243 static constexpr size_t _qt_property_##name##_offset() \
1244 { \
1245 QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1246 return offsetof(Class, name); \
1247 QT_WARNING_POP \
1248 } \
1249 QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, nullptr> name = \
1250 QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, nullptr>( \
1251 value);
1252
1253#define QT_OBJECT_BINDABLE_PROPERTY_WITH_ARGS_5(Class, Type, name, value, Signal) \
1254 static constexpr size_t _qt_property_##name##_offset() \
1255 { \
1256 QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1257 return offsetof(Class, name); \
1258 QT_WARNING_POP \
1259 } \
1260 QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, Signal> name = \
1261 QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, Signal>( \
1262 value);
1263
1264#define Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(...) \
1265 QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1266 QT_OVERLOADED_MACRO(QT_OBJECT_BINDABLE_PROPERTY_WITH_ARGS, __VA_ARGS__) \
1267 QT_WARNING_POP
1268
1269template<typename Class, typename T, auto Offset, auto Getter>
1271{
1272 Class *owner()
1273 {
1274 char *that = reinterpret_cast<char *>(this);
1275 return reinterpret_cast<Class *>(that - QtPrivate::detail::getOffset(Offset));
1276 }
1277 const Class *owner() const
1278 {
1279 char *that = const_cast<char *>(reinterpret_cast<const char *>(this));
1280 return reinterpret_cast<Class *>(that - QtPrivate::detail::getOffset(Offset));
1281 }
1282
1283public:
1284 using value_type = T;
1286
1288
1290 {
1291 qGetBindingStorage(owner())->registerDependency(this);
1292 return (owner()->*Getter)();
1293 }
1294
1295 std::conditional_t<QTypeTraits::is_dereferenceable_v<T>, parameter_type, void>
1297 {
1298 if constexpr (QTypeTraits::is_dereferenceable_v<T>)
1299 return value();
1300 else
1301 return;
1302 }
1303
1305 {
1306 return value();
1307 }
1308
1309 operator parameter_type() const
1310 {
1311 return value();
1312 }
1313
1314 constexpr bool hasBinding() const { return false; }
1315
1316 template<typename Functor>
1318 {
1319 static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1320 return QPropertyChangeHandler<Functor>(*this, f);
1321 }
1322
1323 template<typename Functor>
1325 {
1326 static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1327 f();
1328 return onValueChanged(f);
1329 }
1330
1331 template<typename Functor>
1333 {
1334 static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1335 return QPropertyNotifier(*this, f);
1336 }
1337
1339 {
1340 auto *storage = const_cast<QBindingStorage *>(qGetBindingStorage(owner()));
1341 return *storage->bindingData(const_cast<QObjectComputedProperty *>(this), true);
1342 }
1343
1344 void notify() {
1345 // computed property can't store a binding, so there's nothing to mark
1346 auto *storage = const_cast<QBindingStorage *>(qGetBindingStorage(owner()));
1347 auto bd = storage->bindingData(const_cast<QObjectComputedProperty *>(this), false);
1348 if (bd)
1349 bd->notifyObservers(this, qGetBindingStorage(owner()));
1350 }
1351};
1352
1353#define Q_OBJECT_COMPUTED_PROPERTY(Class, Type, name, ...) \
1354 static constexpr size_t _qt_property_##name##_offset() { \
1355 QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1356 return offsetof(Class, name); \
1357 QT_WARNING_POP \
1358 } \
1359 QObjectComputedProperty<Class, Type, Class::_qt_property_##name##_offset, __VA_ARGS__> name;
1360
1361#undef QT_SOURCE_LOCATION_NAMESPACE
1362
1364
1365#endif // QPROPERTY_H
\inmodule QtCore
\inmodule QtCore
Definition qproperty.h:809
void setValue(const T &value)
Sets the underlying property's value to value.
Definition qproperty.h:883
QBindable(QObject *obj, const QMetaProperty &property)
See \l QBindable::QBindable(QObject *obj, const char *property)
Definition qproperty.h:825
QPropertyBinding< T > makeBinding(const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
Constructs a binding evaluating to the underlying property's value, using a specified source location...
Definition qproperty.h:831
QPropertyBinding< T > takeBinding()
Removes the currently set binding of the underlying property and returns it.
Definition qproperty.h:840
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &binding)
Sets the underlying property's binding to binding.
Definition qproperty.h:846
T value() const
Returns the underlying property's current value.
Definition qproperty.h:873
QPropertyBinding< T > setBinding(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, std::enable_if_t< std::is_invocable_v< Functor > > *=nullptr)
Definition qproperty.h:862
QBindable(QObject *obj, const char *property)
Constructs a QBindable for the \l Q_PROPERTY property on obj.
Definition qproperty.h:828
QBindable(const QUntypedBindable &b)
Definition qproperty.h:817
QPropertyBinding< T > binding() const
Returns the currently set binding of the underlying property.
Definition qproperty.h:835
void registerDependency(const QUntypedPropertyData *data) const
QtPrivate::QPropertyBindingData * bindingData(const QUntypedPropertyData *data) const
\inmodule QtCore
\inmodule QtCore
Definition qmetatype.h:320
int id(int=0) const
Definition qmetatype.h:454
\inmodule QtCore
Definition qproperty.h:1021
QObjectBindableProperty()=default
void setValue(parameter_type t)
Definition qproperty.h:1096
QPropertyNotifier addNotifier(Functor f)
Subscribes the given functor f as a callback that is called whenever the value of the property change...
Definition qproperty.h:1196
typename QPropertyData< T >::rvalue_ref rvalue_ref
Definition qproperty.h:1048
typename QPropertyData< T >::value_type value_type
Definition qproperty.h:1046
void notify()
Programmatically signals a change of the property.
Definition qproperty.h:1107
QPropertyBinding< T > binding() const
Returns the binding expression that is associated with this property.
Definition qproperty.h:1169
typename QPropertyData< T >::arrow_operator_result arrow_operator_result
Definition qproperty.h:1049
arrow_operator_result operator->() const
Definition qproperty.h:1074
parameter_type value() const
Returns the value of the property.
Definition qproperty.h:1068
QObjectBindableProperty(T &&initialValue)
Move-Constructs a property with the provided initialValue.
Definition qproperty.h:1053
QPropertyChangeHandler< Functor > subscribe(Functor f)
Subscribes the given functor f as a callback that is called immediately and whenever the value of the...
Definition qproperty.h:1188
const QtPrivate::QPropertyBindingData & bindingData() const
Definition qproperty.h:1202
void setValue(rvalue_ref t)
Assigns newValue to this property and removes the property's associated binding, if present.
Definition qproperty.h:1112
parameter_type operator*() const
Definition qproperty.h:1086
QObjectBindableProperty(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, typename std::enable_if_t< std::is_invocable_r_v< T, Functor & > > *=nullptr)
Definition qproperty.h:1059
QObjectBindableProperty(const QPropertyBinding< T > &binding)
Definition qproperty.h:1054
bool hasBinding() const
Returns true if the property is associated with a binding; false otherwise.
Definition qproperty.h:1163
QObjectBindableProperty & operator=(rvalue_ref newValue)
Definition qproperty.h:1123
QPropertyBinding< T > setBinding(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, std::enable_if_t< std::is_invocable_v< Functor > > *=nullptr)
Definition qproperty.h:1152
QObjectBindableProperty & operator=(parameter_type newValue)
Definition qproperty.h:1129
typename QPropertyData< T >::parameter_type parameter_type
Definition qproperty.h:1047
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &newBinding)
Associates the value of this property with the provided newBinding expression and returns the previou...
Definition qproperty.h:1135
bool setBinding(const QUntypedPropertyBinding &newBinding)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qproperty.h:1142
QPropertyBinding< T > takeBinding()
Disassociates the binding expression from this property and returns it.
Definition qproperty.h:1175
QObjectBindableProperty(const T &initialValue)
Constructs a property with the provided initialValue.
Definition qproperty.h:1052
QPropertyChangeHandler< Functor > onValueChanged(Functor f)
Registers the given functor f as a callback that shall be called whenever the value of the property c...
Definition qproperty.h:1181
\macro Q_OBJECT_COMPAT_PROPERTY(containingClass, type, name, callback)
Definition qproperty.h:1271
QPropertyChangeHandler< Functor > onValueChanged(Functor f)
Definition qproperty.h:1317
constexpr bool hasBinding() const
Definition qproperty.h:1314
QObjectComputedProperty()=default
std::conditional_t< QTypeTraits::is_dereferenceable_v< T >, parameter_type, void > operator->() const
Definition qproperty.h:1296
QPropertyChangeHandler< Functor > subscribe(Functor f)
Definition qproperty.h:1324
QtPrivate::QPropertyBindingData & bindingData() const
Definition qproperty.h:1338
parameter_type operator*() const
Definition qproperty.h:1304
parameter_type value() const
Definition qproperty.h:1289
QPropertyNotifier addNotifier(Functor f)
Definition qproperty.h:1332
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
\inmodule QtCore
Definition qproperty.h:131
bool hasError() const
Definition qproperty.h:149
QPropertyBinding(const QUntypedPropertyBinding &binding)
Definition qproperty.h:205
QPropertyBinding()=default
QPropertyBinding(Functor &&f, const QPropertyBindingSourceLocation &location)
Definition qproperty.h:199
\inmodule QtCore
Definition qproperty.h:291
Q_NODISCARD_CTOR QPropertyChangeHandler(Functor handler)
Definition qproperty.h:295
Q_NODISCARD_CTOR QPropertyChangeHandler(const Property &property, Functor handler)
Definition qproperty.h:306
\inmodule QtCore
Definition qproperty.h:69
QPropertyData(rvalue_ref t)
Definition qproperty.h:85
typename std::conditional_t< UseReferences, T &&, DisableRValueRefs > rvalue_ref
Definition qproperty.h:79
static constexpr bool UseReferences
Definition qproperty.h:75
std::conditional_t< UseReferences, const T &, T > parameter_type
Definition qproperty.h:78
void setValueBypassingBindings(rvalue_ref v)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qproperty.h:90
std::conditional_t< std::is_pointer_v< T >, const T &, std::conditional_t< QTypeTraits::is_dereferenceable_v< T >, const T &, void > > arrow_operator_result
Definition qproperty.h:81
parameter_type valueBypassingBindings() const
Returns the data stored in this property.
Definition qproperty.h:88
void setValueBypassingBindings(parameter_type v)
Sets the data value stored in this property to v.
Definition qproperty.h:89
QPropertyData()=default
QPropertyData(parameter_type t)
Definition qproperty.h:84
~QPropertyData()=default
\inmodule QtCore
Definition qproperty.h:318
Q_NODISCARD_CTOR QPropertyNotifier(Functor handler)
Definition qproperty.h:325
Q_NODISCARD_CTOR QPropertyNotifier(const Property &property, Functor handler)
Definition qproperty.h:336
Q_NODISCARD_CTOR QPropertyNotifier()=default
QUntypedPropertyData * aliasData
Definition qproperty.h:254
void(*)(QPropertyObserver *, QUntypedPropertyData *) ChangeHandler
Definition qproperty.h:236
ChangeHandler changeHandler
Definition qproperty.h:253
QPropertyBindingPrivate * binding
Definition qproperty.h:252
void setSource(const Property &property)
Definition qproperty.h:267
QUntypedPropertyData * aliasedProperty() const
Definition qproperty.h:277
QPropertyObserver & operator=(QPropertyObserver &&other) noexcept
constexpr QPropertyObserver()=default
\inmodule QtCore
Definition qproperty.h:349
typename QPropertyData< T >::arrow_operator_result arrow_operator_result
Definition qproperty.h:364
QPropertyBinding< T > takeBinding()
Disassociates the binding expression from this property and returns it.
Definition qproperty.h:475
QProperty(const QPropertyBinding< T > &binding)
Constructs a property that is tied to the provided binding expression.
Definition qproperty.h:369
QPropertyChangeHandler< Functor > subscribe(Functor f)
Subscribes the given functor f as a callback that is called immediately and whenever the value of the...
Definition qproperty.h:488
QPropertyChangeHandler< Functor > onValueChanged(Functor f)
Registers the given functor f as a callback that shall be called whenever the value of the property c...
Definition qproperty.h:481
QProperty< T > & operator=(rvalue_ref newValue)
Definition qproperty.h:430
QProperty(rvalue_ref initialValue)
Definition qproperty.h:368
const QtPrivate::QPropertyBindingData & bindingData() const
Definition qproperty.h:502
typename QPropertyData< T >::value_type value_type
Definition qproperty.h:361
bool hasBinding() const
Definition qproperty.h:468
bool setBinding(const QUntypedPropertyBinding &newBinding)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qproperty.h:447
QPropertyBinding< T > binding() const
Returns the binding expression that is associated with this property.
Definition qproperty.h:470
parameter_type value() const
Returns the value of the property.
Definition qproperty.h:384
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &newBinding)
Associates the value of this property with the provided newBinding expression and returns the previou...
Definition qproperty.h:442
void setValue(parameter_type newValue)
Assigns newValue to this property and removes the property's associated binding, if present.
Definition qproperty.h:421
typename QPropertyData< T >::rvalue_ref rvalue_ref
Definition qproperty.h:363
QPropertyBinding< T > setBinding(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, std::enable_if_t< std::is_invocable_v< Functor > > *=nullptr)
Definition qproperty.h:457
void setValue(rvalue_ref newValue)
Definition qproperty.h:412
QProperty()=default
Constructs a property with a default constructed instance of T.
QProperty(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, typename std::enable_if_t< std::is_invocable_r_v< T, Functor & > > *=nullptr)
Definition qproperty.h:374
QProperty< T > & operator=(parameter_type newValue)
Assigns newValue to this property and returns a reference to this QProperty.
Definition qproperty.h:436
typename QPropertyData< T >::parameter_type parameter_type
Definition qproperty.h:362
QPropertyNotifier addNotifier(Functor f)
Subscribes the given functor f as a callback that is called whenever the value of the property change...
Definition qproperty.h:496
arrow_operator_result operator->() const
Definition qproperty.h:390
~QProperty()=default
Destroys the property.
parameter_type operator*() const
Definition qproperty.h:402
QProperty(parameter_type initialValue)
Definition qproperty.h:367
RAII class around Qt::beginPropertyUpdateGroup()/Qt::endPropertyUpdateGroup().
Definition qproperty.h:57
Q_NODISCARD_CTOR QScopedPropertyUpdateGroup()
Calls Qt::beginPropertyUpdateGroup().
Definition qproperty.h:61
~QScopedPropertyUpdateGroup() noexcept(false)
Calls Qt::endPropertyUpdateGroup().
Definition qproperty.h:63
\inmodule QtCore
Definition qshareddata.h:35
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qproperty.h:677
QUntypedPropertyBinding binding() const
Returns the underlying property's binding if there is any, or a default constructed QUntypedPropertyB...
Definition qproperty.h:755
QUntypedPropertyBinding makeBinding(const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
Creates a binding returning the underlying properties' value, using a specified source location.
Definition qproperty.h:701
bool hasBinding() const
Returns true if the underlying property has a binding.
Definition qproperty.h:785
QMetaType metaType() const
Definition qproperty.h:790
const QtPrivate::QBindableInterface * iface
Definition qproperty.h:681
QPropertyChangeHandler< Functor > subscribe(Functor f) const
Behaves like a call to f followed by onValueChanged(f),.
Definition qproperty.h:741
QUntypedPropertyBinding takeBinding()
Removes the currently set binding from the property and returns it.
Definition qproperty.h:706
bool isBindable() const
Definition qproperty.h:698
bool isValid() const
Returns true if the QUntypedBindable is valid.
Definition qproperty.h:697
bool setBinding(const QUntypedPropertyBinding &binding)
Sets the underlying property's binding to binding.
Definition qproperty.h:766
bool isReadOnly() const
Definition qproperty.h:699
QUntypedBindable(Property *p)
Constructs a QUntypedBindable from the property property.
Definition qproperty.h:692
QPropertyNotifier addNotifier(Functor f)
Installs f as a change handler.
Definition qproperty.h:748
constexpr QUntypedBindable(QUntypedPropertyData *d, const QtPrivate::QBindableInterface *i)
Definition qproperty.h:682
QPropertyChangeHandler< Functor > onValueChanged(Functor f) const
Installs f as a change handler.
Definition qproperty.h:733
constexpr QUntypedBindable()=default
Default-constructs a QUntypedBindable.
void observe(QPropertyObserver *observer) const
Definition qproperty.h:721
QMetaType valueMetaType() const
Returns the meta-type of the binding.
QUntypedPropertyBinding()
Constructs a null QUntypedPropertyBinding.
bool isNull() const
Returns true if the QUntypedPropertyBinding is null.
QUntypedPropertyBinding(QMetaType metaType, Functor &&f, const QPropertyBindingSourceLocation &location)
Definition qproperty.h:167
static constexpr QBindableInterface iface
Definition qproperty.h:553
QPropertyBindingPrivate * binding() const
QUntypedPropertyBinding setBinding(const QUntypedPropertyBinding &newBinding, QUntypedPropertyData *propertyDataPtr, QPropertyObserverCallback staticObserverCallback=nullptr, QPropertyBindingWrapper bindingWrapper=nullptr)
QJSValue expected
Definition qjsengine.cpp:12
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
void printMetaTypeMismatch(QMetaType actual, QMetaType expected)
void printUnsuitableBindableWarning(QAnyStringView prefix, BindableWarnings::Reason reason)
void getter(const QUntypedPropertyData *d, void *value)
void setObserver(const QUntypedPropertyData *d, QPropertyObserver *observer)
QUntypedPropertyBinding setBinding(QUntypedPropertyData *d, const QUntypedPropertyBinding &binding, QPropertyBindingWrapper wrapper)
void setter(QUntypedPropertyData *d, const void *value)
bool bindingWrapper(QMetaType type, QUntypedPropertyData *d, QtPrivate::QPropertyBindingFunction binding, QUntypedPropertyData *temp, void *value)
constexpr QBindableInterface iface
Definition qproperty.h:664
QUntypedPropertyBinding makeBinding(const QUntypedPropertyData *d, const QPropertyBindingSourceLocation &location)
Definition qproperty.h:651
QUntypedPropertyBinding getBinding(const QUntypedPropertyData *d)
constexpr size_t getOffset(size_t o)
\macro QT_NAMESPACE
bool(*)(QMetaType, QUntypedPropertyData *dataPtr, QPropertyBindingFunction) QPropertyBindingWrapper
auto makePropertyBinding(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, std::enable_if_t< std::is_invocable_v< Functor > > *=nullptr)
Definition qproperty.h:212
Q_CORE_EXPORT void beginPropertyUpdateGroup()
Q_CORE_EXPORT void endPropertyUpdateGroup()
#define Q_NODISCARD_CTOR
#define QT_POST_CXX17_API_IN_EXPORTED_CLASS
#define QT_WARNING_POP
#define QT_WARNING_DISABLE_DEPRECATED
#define QT_WARNING_PUSH
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
quint16 Offset
static const QMetaObjectPrivate * priv(const uint *data)
const QBindingStorage * qGetBindingStorage(const QObject *o)
Definition qobject.h:429
GLint location
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLboolean r
[2]
GLfloat GLfloat f
GLenum type
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
GLhandleARB obj
[2]
GLuint GLfloat * val
GLdouble GLdouble t
Definition qopenglext.h:243
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
#define QT_PROPERTY_DEFAULT_BINDING_LOCATION
Definition qproperty.h:46
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QT_DEPRECATED_X(text)
#define QT_DEPRECATED
unsigned int quint32
Definition qtypes.h:45
size_t quintptr
Definition qtypes.h:72
const char property[13]
Definition qwizard.cpp:101
settings setValue("DataPump/bgcolor", color)
QStorageInfo storage
[1]
QSharedPointer< T > other(t)
[5]
void(*)(const QUntypedPropertyData *d, void *value) Getter
Definition qproperty.h:528
QUntypedPropertyBinding(*)(QUntypedPropertyData *d, const QUntypedPropertyBinding &binding) BindingSetter
Definition qproperty.h:531
void(*)(const QUntypedPropertyData *d, QPropertyObserver *observer) SetObserver
Definition qproperty.h:533
void(*)(QUntypedPropertyData *d, const void *value) Setter
Definition qproperty.h:529
QUntypedPropertyBinding(*)(const QUntypedPropertyData *d, const QPropertyBindingSourceLocation &location) MakeBinding
Definition qproperty.h:532
QUntypedPropertyBinding(*)(const QUntypedPropertyData *d) BindingGetter
Definition qproperty.h:530
static constexpr quintptr MetaTypeAccessorFlag
Definition qproperty.h:543
Definition moc.h:24
void wrapper()