QtBase  v6.3.1
qproperty.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2020 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QPROPERTY_H
41 #define QPROPERTY_H
42 
43 #include <QtCore/qglobal.h>
44 #include <QtCore/qshareddata.h>
45 #include <QtCore/qstring.h>
46 #include <QtCore/qbindingstorage.h>
47 
48 #include <type_traits>
49 
50 #include <QtCore/qpropertyprivate.h>
51 
52 #if __has_include(<source_location>) && __cplusplus >= 202002L && !defined(Q_CLANG_QDOC)
53 #include <source_location>
54 #if defined(__cpp_lib_source_location)
55 #define QT_SOURCE_LOCATION_NAMESPACE std
56 #define QT_PROPERTY_COLLECT_BINDING_LOCATION
57 #define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation(std::source_location::current())
58 #endif
59 #endif
60 
61 #if __has_include(<experimental/source_location>) && !defined(Q_CLANG_QDOC)
62 #include <experimental/source_location>
63 #if !defined(QT_PROPERTY_COLLECT_BINDING_LOCATION)
64 #if defined(__cpp_lib_experimental_source_location)
65 #define QT_SOURCE_LOCATION_NAMESPACE std::experimental
66 #define QT_PROPERTY_COLLECT_BINDING_LOCATION
67 #define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation(std::experimental::source_location::current())
68 #endif // defined(__cpp_lib_experimental_source_location)
69 #endif
70 #endif
71 
72 #if !defined(QT_PROPERTY_COLLECT_BINDING_LOCATION)
73 #define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation()
74 #endif
75 
77 
78 namespace Qt {
79 Q_CORE_EXPORT void beginPropertyUpdateGroup();
80 Q_CORE_EXPORT void endPropertyUpdateGroup();
81 }
82 
83 template <typename T>
85 {
86 protected:
87  mutable T val = T();
88 private:
89  class DisableRValueRefs {};
90 protected:
91  static constexpr bool UseReferences = !(std::is_arithmetic_v<T> || std::is_enum_v<T> || std::is_pointer_v<T>);
92 public:
93  using value_type = T;
94  using parameter_type = std::conditional_t<UseReferences, const T &, T>;
95  using rvalue_ref = typename std::conditional_t<UseReferences, T &&, DisableRValueRefs>;
96  using arrow_operator_result = std::conditional_t<std::is_pointer_v<T>, const T &,
97  std::conditional_t<QTypeTraits::is_dereferenceable_v<T>, const T &, void>>;
98 
99  QPropertyData() = default;
102  ~QPropertyData() = default;
103 
106  void setValueBypassingBindings(rvalue_ref v) { val = std::move(v); }
107 };
108 
109 // ### Qt 7: un-export
110 struct Q_CORE_EXPORT QPropertyBindingSourceLocation
111 {
112  const char *fileName = nullptr;
113  const char *functionName = nullptr;
117 #ifdef __cpp_lib_source_location
118  constexpr QPropertyBindingSourceLocation(const std::source_location &cppLocation)
119  {
120  fileName = cppLocation.file_name();
121  functionName = cppLocation.function_name();
122  line = cppLocation.line();
123  column = cppLocation.column();
124  }
125 #endif
126 #ifdef __cpp_lib_experimental_source_location
127  constexpr QPropertyBindingSourceLocation(const std::experimental::source_location &cppLocation)
128  {
129  fileName = cppLocation.file_name();
130  functionName = cppLocation.function_name();
131  line = cppLocation.line();
132  column = cppLocation.column();
133  }
134 #endif
135 };
136 
137 template <typename Functor> class QPropertyChangeHandler;
139 
140 class Q_CORE_EXPORT QPropertyBindingError
141 {
142 public:
143  enum Type {
147  UnknownError
148  };
149 
151  QPropertyBindingError(Type type, const QString &description = QString());
152 
158 
159  bool hasError() const { return d.get() != nullptr; }
160  Type type() const;
161  QString description() const;
162 
163 private:
165 };
166 
167 class Q_CORE_EXPORT QUntypedPropertyBinding
168 {
169 public:
170  // writes binding result into dataPtr
172 
174  QUntypedPropertyBinding(QMetaType metaType, const BindingFunctionVTable *vtable, void *function, const QPropertyBindingSourceLocation &location);
175 
176  template<typename Functor>
178  : QUntypedPropertyBinding(metaType, &QtPrivate::bindingFunctionVTable<std::remove_reference_t<Functor>>, &f, location)
179  {}
180 
186 
187  bool isNull() const;
188 
190 
191  QMetaType valueMetaType() const;
192 
194 private:
197  template <typename> friend class QPropertyBinding;
199 };
200 
201 template <typename PropertyType>
203 {
204 
205 public:
206  QPropertyBinding() = default;
207 
208  template<typename Functor>
210  : QUntypedPropertyBinding(QMetaType::fromType<PropertyType>(), &QtPrivate::bindingFunctionVTable<std::remove_reference_t<Functor>, PropertyType>, &f, location)
211  {}
212 
213 
214  // Internal
215  explicit QPropertyBinding(const QUntypedPropertyBinding &binding)
216  : QUntypedPropertyBinding(binding)
217  {}
218 };
219 
220 namespace Qt {
221  template <typename Functor>
223  std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
224  {
225  return QPropertyBinding<std::invoke_result_t<Functor>>(std::forward<Functor>(f), location);
226  }
227 }
228 
229 struct QPropertyObserverPrivate;
231 class QPropertyObserver;
232 
234 {
235 public:
236  // Internal
237  enum ObserverTag {
238  ObserverNotifiesBinding, // observer was installed to notify bindings that obsverved property changed
239  ObserverNotifiesChangeHandler, // observer is a change handler, which runs on every change
240  ObserverIsPlaceholder, // the observer before this one is currently evaluated in QPropertyObserver::notifyObservers.
242  };
243 protected:
245 
246 private:
249  friend class QPropertyObserver;
253 
255  // prev is a pointer to the "next" element within the previous node, or to the "firstObserverPtr" if it is the
256  // first node.
258 
259  union {
263  };
264 };
265 
266 class Q_CORE_EXPORT QPropertyObserver : public QPropertyObserverBase
267 {
268 public:
269  constexpr QPropertyObserver() = default;
271  QPropertyObserver &operator=(QPropertyObserver &&other) noexcept;
273 
274  template<typename Property, typename = typename Property::InheritsQUntypedPropertyData>
276  { setSource(property.bindingData()); }
277  void setSource(const QtPrivate::QPropertyBindingData &property);
278 
279 protected:
280  QPropertyObserver(ChangeHandler changeHandler);
281  QPropertyObserver(QUntypedPropertyData *aliasedPropertyPtr);
282 
284  {
285  return aliasData;
286  }
287 
288 private:
289 
290  QPropertyObserver(const QPropertyObserver &) = delete;
291  QPropertyObserver &operator=(const QPropertyObserver &) = delete;
292 
293 };
294 
295 template <typename Functor>
296 class [[nodiscard]] QPropertyChangeHandler : public QPropertyObserver
297 {
298  Functor m_handler;
299 public:
302  auto This = static_cast<QPropertyChangeHandler<Functor>*>(self);
303  This->m_handler();
304  })
305  , m_handler(handler)
306  {
307  }
308 
309  template<typename Property, typename = typename Property::InheritsQUntypedPropertyData>
312  auto This = static_cast<QPropertyChangeHandler<Functor>*>(self);
313  This->m_handler();
314  })
315  , m_handler(handler)
316  {
318  }
319 };
320 
321 class [[nodiscard]] QPropertyNotifier : public QPropertyObserver
322 {
323  std::function<void()> m_handler;
324 public:
325  QPropertyNotifier() = default;
326  template<typename Functor>
329  auto This = static_cast<QPropertyNotifier *>(self);
330  This->m_handler();
331  })
332  , m_handler(handler)
333  {
334  }
335 
336  template<typename Functor, typename Property, typename = typename Property::InheritsQUntypedPropertyData>
339  auto This = static_cast<QPropertyNotifier *>(self);
340  This->m_handler();
341  })
342  , m_handler(handler)
343  {
345  }
346 };
347 
348 template <typename T>
349 class QProperty : public QPropertyData<T>
350 {
352  bool is_equal(const T &v)
353  {
354  if constexpr (QTypeTraits::has_operator_equal_v<T>) {
355  if (v == this->val)
356  return true;
357  }
358  return false;
359  }
360 
361 public:
366 
367  QProperty() = default;
368  explicit QProperty(parameter_type initialValue) : QPropertyData<T>(initialValue) {}
369  explicit QProperty(rvalue_ref initialValue) : QPropertyData<T>(std::move(initialValue)) {}
371  : QProperty()
372  { setBinding(binding); }
373 #ifndef Q_CLANG_QDOC
374  template <typename Functor>
376  typename std::enable_if_t<std::is_invocable_r_v<T, Functor&>> * = nullptr)
377  : QProperty(QPropertyBinding<T>(std::forward<Functor>(f), location))
378  {}
379 #else
380  template <typename Functor>
381  explicit QProperty(Functor &&f);
382 #endif
383  ~QProperty() = default;
384 
386  {
387  d.registerWithCurrentlyEvaluatingBinding();
388  return this->val;
389  }
390 
392  {
393  if constexpr (QTypeTraits::is_dereferenceable_v<T>) {
394  return value();
395  } else if constexpr (std::is_pointer_v<T>) {
396  value();
397  return this->val;
398  } else {
399  return;
400  }
401  }
402 
404  {
405  return value();
406  }
407 
408  operator parameter_type() const
409  {
410  return value();
411  }
412 
413  void setValue(rvalue_ref newValue)
414  {
415  d.removeBinding();
416  if (is_equal(newValue))
417  return;
418  this->val = std::move(newValue);
419  notify();
420  }
421 
422  void setValue(parameter_type newValue)
423  {
424  d.removeBinding();
425  if (is_equal(newValue))
426  return;
427  this->val = newValue;
428  notify();
429  }
430 
432  {
433  setValue(std::move(newValue));
434  return *this;
435  }
436 
438  {
439  setValue(newValue);
440  return *this;
441  }
442 
444  {
445  return QPropertyBinding<T>(d.setBinding(newBinding, this));
446  }
447 
448  bool setBinding(const QUntypedPropertyBinding &newBinding)
449  {
450  if (!newBinding.isNull() && newBinding.valueMetaType().id() != qMetaTypeId<T>())
451  return false;
452  setBinding(static_cast<const QPropertyBinding<T> &>(newBinding));
453  return true;
454  }
455 
456 #ifndef Q_CLANG_QDOC
457  template <typename Functor>
460  std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
461  {
462  return setBinding(Qt::makePropertyBinding(std::forward<Functor>(f), location));
463  }
464 #else
465  template <typename Functor>
467 #endif
468 
469  bool hasBinding() const { return d.hasBinding(); }
470 
472  {
473  return QPropertyBinding<T>(QUntypedPropertyBinding(d.binding()));
474  }
475 
477  {
478  return QPropertyBinding<T>(d.setBinding(QUntypedPropertyBinding(), this));
479  }
480 
481  template<typename Functor>
483  {
484  static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
485  return QPropertyChangeHandler<Functor>(*this, f);
486  }
487 
488  template<typename Functor>
490  {
491  static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
492  f();
493  return onValueChanged(f);
494  }
495 
496  template<typename Functor>
498  {
499  static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
500  return QPropertyNotifier(*this, f);
501  }
502 
503  const QtPrivate::QPropertyBindingData &bindingData() const { return d; }
504 private:
505  void notify()
506  {
507  d.notifyObservers(this);
508  }
509 
511 };
512 
513 namespace Qt {
514  template <typename PropertyType>
518  {
519  return Qt::makePropertyBinding([&otherProperty]() -> PropertyType { return otherProperty; }, location);
520  }
521 }
522 
523 
524 namespace QtPrivate
525 {
526 
528 {
529  using Getter = void (*)(const QUntypedPropertyData *d, void *value);
530  using Setter = void (*)(QUntypedPropertyData *d, const void *value);
534  using SetObserver = void (*)(const QUntypedPropertyData *d, QPropertyObserver *observer);
535  using GetMetaType = QMetaType (*)();
543 
544  static constexpr quintptr MetaTypeAccessorFlag = 0x1;
545 };
546 
547 template<typename Property, typename = void>
549 {
550  using T = typename Property::value_type;
551 public:
552  // interface for computed properties. Those do not have a binding()/setBinding() method, but one can
553  // install observers on them.
554  static constexpr QBindableInterface iface = {
555  [](const QUntypedPropertyData *d, void *value) -> void
556  { *static_cast<T*>(value) = static_cast<const Property *>(d)->value(); },
557  nullptr,
558  nullptr,
559  nullptr,
561  { return Qt::makePropertyBinding([d]() -> T { return static_cast<const Property *>(d)->value(); }, location); },
562  [](const QUntypedPropertyData *d, QPropertyObserver *observer) -> void
563  { observer->setSource(static_cast<const Property *>(d)->bindingData()); },
564  []() { return QMetaType::fromType<T>(); }
565  };
566 };
567 
568 template<typename Property>
569 class QBindableInterfaceForProperty<const Property, std::void_t<decltype(std::declval<Property>().binding())>>
570 {
571  using T = typename Property::value_type;
572 public:
573  // A bindable created from a const property results in a read-only interface, too.
574  static constexpr QBindableInterface iface = {
575 
576  [](const QUntypedPropertyData *d, void *value) -> void
577  { *static_cast<T*>(value) = static_cast<const Property *>(d)->value(); },
578  /*setter=*/nullptr,
580  { return static_cast<const Property *>(d)->binding(); },
581  /*setBinding=*/nullptr,
583  { return Qt::makePropertyBinding([d]() -> T { return static_cast<const Property *>(d)->value(); }, location); },
584  [](const QUntypedPropertyData *d, QPropertyObserver *observer) -> void
585  { observer->setSource(static_cast<const Property *>(d)->bindingData()); },
586  []() { return QMetaType::fromType<T>(); }
587  };
588 };
589 
590 template<typename Property>
591 class QBindableInterfaceForProperty<Property, std::void_t<decltype(std::declval<Property>().binding())>>
592 {
593  using T = typename Property::value_type;
594 public:
595  static constexpr QBindableInterface iface = {
596  [](const QUntypedPropertyData *d, void *value) -> void
597  { *static_cast<T*>(value) = static_cast<const Property *>(d)->value(); },
598  [](QUntypedPropertyData *d, const void *value) -> void
599  { static_cast<Property *>(d)->setValue(*static_cast<const T*>(value)); },
601  { return static_cast<const Property *>(d)->binding(); },
603  { return static_cast<Property *>(d)->setBinding(static_cast<const QPropertyBinding<T> &>(binding)); },
605  { return Qt::makePropertyBinding([d]() -> T { return static_cast<const Property *>(d)->value(); }, location); },
606  [](const QUntypedPropertyData *d, QPropertyObserver *observer) -> void
607  { observer->setSource(static_cast<const Property *>(d)->bindingData()); },
608  []() { return QMetaType::fromType<T>(); }
609  };
610 };
611 
612 }
613 
614 namespace QtPrivate {
615 // used in Q(Untyped)Bindable to print warnings about various binding errors
616 namespace BindableWarnings {
618 Q_CORE_EXPORT void printUnsuitableBindableWarning(QAnyStringView prefix, Reason reason);
619 Q_CORE_EXPORT void printMetaTypeMismatch(QMetaType actual, QMetaType expected);
620 }
621 }
622 
624 {
625  friend struct QUntypedBindablePrivate; // allows access to internal data
626 protected:
630  : data(d), iface(i)
631  {}
632 
633 public:
634  constexpr QUntypedBindable() = default;
635  template<typename Property>
637  : data(const_cast<std::remove_cv_t<Property> *>(p)),
638  iface(&QtPrivate::QBindableInterfaceForProperty<Property>::iface)
639  { Q_ASSERT(data && iface); }
640 
641  bool isValid() const { return data != nullptr; }
642  bool isBindable() const { return iface && iface->getBinding; }
643  bool isReadOnly() const { return !(iface && iface->setBinding && iface->setObserver); }
644 
646  {
648  }
649 
651  {
652  if (!iface)
653  return QUntypedPropertyBinding {};
654  // We do not have a dedicated takeBinding function pointer in the interface
655  // therefore we synthesize takeBinding by retrieving the binding with binding
656  // and calling setBinding with a default constructed QUntypedPropertyBinding
657  // afterwards.
658  if (!(iface->getBinding && iface->setBinding))
659  return QUntypedPropertyBinding {};
662  return binding;
663  }
664 
665  void observe(QPropertyObserver *observer) const
666  {
667  if (iface)
668  iface->setObserver(data, observer);
669 #ifndef QT_NO_DEBUG
670  else
673 #endif
674  }
675 
676  template<typename Functor>
678  {
680  observe(&handler);
681  return handler;
682  }
683 
684  template<typename Functor>
686  {
687  f();
688  return onValueChanged(f);
689  }
690 
691  template<typename Functor>
693  {
694  QPropertyNotifier handler(f);
695  observe(&handler);
696  return handler;
697  }
698 
700  {
701  if (!isBindable()) {
702 #ifndef QT_NO_DEBUG
705 #endif
706  return QUntypedPropertyBinding();
707  }
708  return iface->getBinding(data);
709  }
711  {
712  if (isReadOnly()) {
713 #ifndef QT_NO_DEBUG
714  const auto errorType = iface ? QtPrivate::BindableWarnings::ReadOnlyInterface :
716  QtPrivate::BindableWarnings::printUnsuitableBindableWarning("setBinding: Could not set binding via bindable interface.", errorType);
717 #endif
718  return false;
719  }
720  if (!binding.isNull() && binding.valueMetaType() != metaType()) {
721 #ifndef QT_NO_DEBUG
723 #endif
724  return false;
725  }
727  return true;
728  }
729  bool hasBinding() const
730  {
731  return !binding().isNull();
732  }
733 
735  {
736  if (!(iface && data))
737  return QMetaType();
738  if (iface->metaType)
739  return iface->metaType();
740  // ### Qt 7: Change the metatype function to take data as its argument
741  // special casing for QML's proxy bindable: allow multiplexing in the getter
742  // function to retrieve the metatype from data
746  return result;
747  }
748 
749 };
750 
751 template<typename T>
753 {
754  template<typename U>
755  friend class QPropertyAlias;
757  : QUntypedBindable(d, i)
758  {}
759 public:
762  {
763  if (iface && metaType() != QMetaType::fromType<T>()) {
764  data = nullptr;
765  iface = nullptr;
766  }
767  }
768 
770  {
772  }
774  {
775  return static_cast<QPropertyBinding<T> &&>(QUntypedBindable::binding());
776  }
777 
779  {
780  return static_cast<QPropertyBinding<T> &&>(QUntypedBindable::takeBinding());
781  }
782 
785  {
786  Q_ASSERT(!iface || binding.isNull() || binding.valueMetaType() == metaType());
787 
788  if (iface && iface->setBinding)
789  return static_cast<QPropertyBinding<T> &&>(iface->setBinding(data, binding));
790 #ifndef QT_NO_DEBUG
791  if (!iface)
793  else
794  QtPrivate::BindableWarnings::printUnsuitableBindableWarning("setBinding: Could not set binding via bindable interface.", QtPrivate::BindableWarnings::ReadOnlyInterface);
795 #endif
796  return QPropertyBinding<T>();
797  }
798 #ifndef Q_CLANG_QDOC
799  template <typename Functor>
802  std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
803  {
804  return setBinding(Qt::makePropertyBinding(std::forward<Functor>(f), location));
805  }
806 #else
807  template <typename Functor>
809 #endif
810 
811  T value() const
812  {
813  if (iface) {
814  T result;
815  iface->getter(data, &result);
816  return result;
817  }
818  return T{};
819  }
820 
821  void setValue(const T &value)
822  {
823  if (iface && iface->setter)
824  iface->setter(data, &value);
825  }
826 };
827 
828 template<typename T>
830 {
832  const QtPrivate::QBindableInterface *iface = nullptr;
833 
834 public:
837  iface(&QtPrivate::QBindableInterfaceForProperty<QProperty<T>>::iface)
838  {
839  if (iface)
840  iface->setObserver(aliasedProperty(), this);
841  }
842 
843  template<typename Property, typename = typename Property::InheritsQUntypedPropertyData>
846  iface(&QtPrivate::QBindableInterfaceForProperty<Property>::iface)
847  {
848  if (iface)
849  iface->setObserver(aliasedProperty(), this);
850  }
851 
854  iface(alias->iface)
855  {
856  if (iface)
857  iface->setObserver(aliasedProperty(), this);
858  }
859 
862  iface(property.iface)
863  {
864  if (iface)
865  iface->setObserver(aliasedProperty(), this);
866  }
867 
868  T value() const
869  {
870  T t = T();
871  if (auto *p = aliasedProperty())
872  iface->getter(p, &t);
873  return t;
874  }
875 
876  operator T() const { return value(); }
877 
878  void setValue(const T &newValue)
879  {
880  if (auto *p = aliasedProperty())
881  iface->setter(p, &newValue);
882  }
883 
884  QPropertyAlias<T> &operator=(const T &newValue)
885  {
886  setValue(newValue);
887  return *this;
888  }
889 
891  {
892  return QBindable<T>(aliasedProperty(), iface).setBinding(newBinding);
893  }
894 
895  bool setBinding(const QUntypedPropertyBinding &newBinding)
896  {
897  return QBindable<T>(aliasedProperty(), iface).setBinding(newBinding);
898  }
899 
900 #ifndef Q_CLANG_QDOC
901  template <typename Functor>
904  std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
905  {
906  return setBinding(Qt::makePropertyBinding(std::forward<Functor>(f), location));
907  }
908 #else
909  template <typename Functor>
911 #endif
912 
913  bool hasBinding() const
914  {
915  return QBindable<T>(aliasedProperty(), iface).hasBinding();
916  }
917 
919  {
920  return QBindable<T>(aliasedProperty(), iface).binding();
921  }
922 
924  {
925  return QBindable<T>(aliasedProperty(), iface).takeBinding();
926  }
927 
928  template<typename Functor>
930  {
931  return QBindable<T>(aliasedProperty(), iface).onValueChanged(f);
932  }
933 
934  template<typename Functor>
936  {
937  return QBindable<T>(aliasedProperty(), iface).subscribe(f);
938  }
939 
940  template<typename Functor>
942  {
943  return QBindable<T>(aliasedProperty(), iface).notify(f);
944  }
945 
946  bool isValid() const
947  {
948  return aliasedProperty() != nullptr;
949  }
950 };
951 
952 template<typename Class, typename T, auto Offset, auto Signal = nullptr>
954 {
956  static bool constexpr HasSignal = !std::is_same_v<decltype(Signal), std::nullptr_t>;
957  using SignalTakesValue = std::is_invocable<decltype(Signal), Class, T>;
958  Class *owner()
959  {
960  char *that = reinterpret_cast<char *>(this);
961  return reinterpret_cast<Class *>(that - QtPrivate::detail::getOffset(Offset));
962  }
963  const Class *owner() const
964  {
965  char *that = const_cast<char *>(reinterpret_cast<const char *>(this));
966  return reinterpret_cast<Class *>(that - QtPrivate::detail::getOffset(Offset));
967  }
968  static void signalCallBack(QUntypedPropertyData *o)
969  {
970  QObjectBindableProperty *that = static_cast<QObjectBindableProperty *>(o);
971  if constexpr (HasSignal) {
972  if constexpr (SignalTakesValue::value)
973  (that->owner()->*Signal)(that->valueBypassingBindings());
974  else
975  (that->owner()->*Signal)();
976  }
977  }
978 public:
983 
985  explicit QObjectBindableProperty(const T &initialValue) : QPropertyData<T>(initialValue) {}
986  explicit QObjectBindableProperty(T &&initialValue) : QPropertyData<T>(std::move(initialValue)) {}
989  { setBinding(binding); }
990 #ifndef Q_CLANG_QDOC
991  template <typename Functor>
993  typename std::enable_if_t<std::is_invocable_r_v<T, Functor&>> * = nullptr)
995  {}
996 #else
997  template <typename Functor>
998  explicit QObjectBindableProperty(Functor &&f);
999 #endif
1000 
1002  {
1003  qGetBindingStorage(owner())->registerDependency(this);
1004  return this->val;
1005  }
1006 
1008  {
1009  if constexpr (QTypeTraits::is_dereferenceable_v<T>) {
1010  return value();
1011  } else if constexpr (std::is_pointer_v<T>) {
1012  value();
1013  return this->val;
1014  } else {
1015  return;
1016  }
1017  }
1018 
1020  {
1021  return value();
1022  }
1023 
1024  operator parameter_type() const
1025  {
1026  return value();
1027  }
1028 
1030  {
1031  auto *bd = qGetBindingStorage(owner())->bindingData(this);
1032  if (bd)
1033  bd->removeBinding();
1034  if (this->val == t)
1035  return;
1036  this->val = t;
1037  notify(bd);
1038  }
1039 
1040  void notify() {
1041  auto *bd = qGetBindingStorage(owner())->bindingData(this);
1042  notify(bd);
1043  }
1044 
1046  {
1047  auto *bd = qGetBindingStorage(owner())->bindingData(this);
1048  if (bd)
1049  bd->removeBinding();
1050  if (this->val == t)
1051  return;
1052  this->val = std::move(t);
1053  notify(bd);
1054  }
1055 
1057  {
1058  setValue(std::move(newValue));
1059  return *this;
1060  }
1061 
1063  {
1064  setValue(newValue);
1065  return *this;
1066  }
1067 
1069  {
1071  QUntypedPropertyBinding oldBinding(bd->setBinding(newBinding, this, HasSignal ? &signalCallBack : nullptr));
1072  return static_cast<QPropertyBinding<T> &>(oldBinding);
1073  }
1074 
1075  bool setBinding(const QUntypedPropertyBinding &newBinding)
1076  {
1077  if (!newBinding.isNull() && newBinding.valueMetaType().id() != qMetaTypeId<T>())
1078  return false;
1079  setBinding(static_cast<const QPropertyBinding<T> &>(newBinding));
1080  return true;
1081  }
1082 
1083 #ifndef Q_CLANG_QDOC
1084  template <typename Functor>
1087  std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
1088  {
1089  return setBinding(Qt::makePropertyBinding(std::forward<Functor>(f), location));
1090  }
1091 #else
1092  template <typename Functor>
1094 #endif
1095 
1096  bool hasBinding() const
1097  {
1098  auto *bd = qGetBindingStorage(owner())->bindingData(this);
1099  return bd && bd->binding() != nullptr;
1100  }
1101 
1103  {
1104  auto *bd = qGetBindingStorage(owner())->bindingData(this);
1105  return static_cast<QPropertyBinding<T> &&>(QUntypedPropertyBinding(bd ? bd->binding() : nullptr));
1106  }
1107 
1109  {
1110  return setBinding(QPropertyBinding<T>());
1111  }
1112 
1113  template<typename Functor>
1115  {
1116  static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1117  return QPropertyChangeHandler<Functor>(*this, f);
1118  }
1119 
1120  template<typename Functor>
1122  {
1123  static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1124  f();
1125  return onValueChanged(f);
1126  }
1127 
1128  template<typename Functor>
1130  {
1131  static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1132  return QPropertyNotifier(*this, f);
1133  }
1134 
1136  {
1137  auto *storage = const_cast<QBindingStorage *>(qGetBindingStorage(owner()));
1138  return *storage->bindingData(const_cast<ThisType *>(this), true);
1139  }
1140 private:
1142  {
1143  if (binding)
1144  binding->notifyObservers(this, qGetBindingStorage(owner()));
1145  if constexpr (HasSignal) {
1146  if constexpr (SignalTakesValue::value)
1147  (owner()->*Signal)(this->valueBypassingBindings());
1148  else
1149  (owner()->*Signal)();
1150  }
1151  }
1152 };
1153 
1154 #define QT_OBJECT_BINDABLE_PROPERTY_3(Class, Type, name) \
1155  static constexpr size_t _qt_property_##name##_offset() { \
1156  QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1157  return offsetof(Class, name); \
1158  QT_WARNING_POP \
1159  } \
1160  QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, nullptr> name;
1161 
1162 #define QT_OBJECT_BINDABLE_PROPERTY_4(Class, Type, name, Signal) \
1163  static constexpr size_t _qt_property_##name##_offset() { \
1164  QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1165  return offsetof(Class, name); \
1166  QT_WARNING_POP \
1167  } \
1168  QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, Signal> name;
1169 
1170 #define Q_OBJECT_BINDABLE_PROPERTY(...) \
1171  QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1172  QT_OVERLOADED_MACRO(QT_OBJECT_BINDABLE_PROPERTY, __VA_ARGS__) \
1173  QT_WARNING_POP
1174 
1175 #define QT_OBJECT_BINDABLE_PROPERTY_WITH_ARGS_4(Class, Type, name, value) \
1176  static constexpr size_t _qt_property_##name##_offset() \
1177  { \
1178  QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1179  return offsetof(Class, name); \
1180  QT_WARNING_POP \
1181  } \
1182  QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, nullptr> name = \
1183  QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, nullptr>( \
1184  value);
1185 
1186 #define QT_OBJECT_BINDABLE_PROPERTY_WITH_ARGS_5(Class, Type, name, value, Signal) \
1187  static constexpr size_t _qt_property_##name##_offset() \
1188  { \
1189  QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1190  return offsetof(Class, name); \
1191  QT_WARNING_POP \
1192  } \
1193  QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, Signal> name = \
1194  QObjectBindableProperty<Class, Type, Class::_qt_property_##name##_offset, Signal>( \
1195  value);
1196 
1197 #define Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(...) \
1198  QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1199  QT_OVERLOADED_MACRO(QT_OBJECT_BINDABLE_PROPERTY_WITH_ARGS, __VA_ARGS__) \
1200  QT_WARNING_POP
1201 
1202 template<typename Class, typename T, auto Offset, auto Getter>
1204 {
1205  Class *owner()
1206  {
1207  char *that = reinterpret_cast<char *>(this);
1208  return reinterpret_cast<Class *>(that - QtPrivate::detail::getOffset(Offset));
1209  }
1210  const Class *owner() const
1211  {
1212  char *that = const_cast<char *>(reinterpret_cast<const char *>(this));
1213  return reinterpret_cast<Class *>(that - QtPrivate::detail::getOffset(Offset));
1214  }
1215 
1216 public:
1217  using value_type = T;
1219 
1221 
1223  {
1224  qGetBindingStorage(owner())->registerDependency(this);
1225  return (owner()->*Getter)();
1226  }
1227 
1228  std::conditional_t<QTypeTraits::is_dereferenceable_v<T>, parameter_type, void>
1229  operator->() const
1230  {
1231  if constexpr (QTypeTraits::is_dereferenceable_v<T>)
1232  return value();
1233  else
1234  return;
1235  }
1236 
1238  {
1239  return value();
1240  }
1241 
1242  operator parameter_type() const
1243  {
1244  return value();
1245  }
1246 
1247  constexpr bool hasBinding() const { return false; }
1248 
1249  template<typename Functor>
1251  {
1252  static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1253  return QPropertyChangeHandler<Functor>(*this, f);
1254  }
1255 
1256  template<typename Functor>
1258  {
1259  static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1260  f();
1261  return onValueChanged(f);
1262  }
1263 
1264  template<typename Functor>
1266  {
1267  static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
1268  return QPropertyNotifier(*this, f);
1269  }
1270 
1272  {
1273  auto *storage = const_cast<QBindingStorage *>(qGetBindingStorage(owner()));
1274  return *storage->bindingData(const_cast<QObjectComputedProperty *>(this), true);
1275  }
1276 
1277  void notify() {
1278  // computed property can't store a binding, so there's nothing to mark
1279  auto *storage = const_cast<QBindingStorage *>(qGetBindingStorage(owner()));
1280  auto bd = storage->bindingData(const_cast<QObjectComputedProperty *>(this), false);
1281  if (bd)
1282  bd->notifyObservers(this, qGetBindingStorage(owner()));
1283  }
1284 };
1285 
1286 #define Q_OBJECT_COMPUTED_PROPERTY(Class, Type, name, ...) \
1287  static constexpr size_t _qt_property_##name##_offset() { \
1288  QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF \
1289  return offsetof(Class, name); \
1290  QT_WARNING_POP \
1291  } \
1292  QObjectComputedProperty<Class, Type, Class::_qt_property_##name##_offset, __VA_ARGS__> name;
1293 
1294 #undef QT_SOURCE_LOCATION_NAMESPACE
1295 
1297 
1298 #endif // QPROPERTY_H
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
#define value
[5]
FT_Error error
Definition: cffdrivr.c:657
QBindable is a wrapper class around binding-enabled properties. It allows type-safe operations while ...
Definition: qproperty.h:753
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:800
void setValue(const T &value)
Definition: qproperty.h:821
QPropertyBinding< T > makeBinding(const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
Definition: qproperty.h:769
QPropertyBinding< T > takeBinding()
Definition: qproperty.h:778
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &binding)
Definition: qproperty.h:784
bool setBinding(const QUntypedPropertyBinding &binding)
Definition: qproperty.h:710
T value() const
Definition: qproperty.h:811
QBindable(const QUntypedBindable &b)
Definition: qproperty.h:761
QPropertyBinding< T > binding() const
Definition: qproperty.h:773
QtPrivate::QPropertyBindingData * bindingData(const QUntypedPropertyData *data) const
void registerDependency(const QUntypedPropertyData *data) const
The QMetaType class manages named types in the meta-object system.
Definition: qmetatype.h:328
int id(int=0) const
Definition: qmetatype.h:453
The QObjectBindableProperty class is a template class that enables automatic property bindings for pr...
Definition: qproperty.h:954
QObjectBindableProperty & operator=(parameter_type newValue)
Definition: qproperty.h:1062
QObjectBindableProperty()=default
void setValue(parameter_type t)
Definition: qproperty.h:1029
QObjectBindableProperty & operator=(rvalue_ref newValue)
Definition: qproperty.h:1056
QPropertyNotifier addNotifier(Functor f)
Definition: qproperty.h:1129
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:992
QPropertyBinding< T > binding() const
Definition: qproperty.h:1102
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:1085
arrow_operator_result operator->() const
Definition: qproperty.h:1007
parameter_type value() const
Definition: qproperty.h:1001
QObjectBindableProperty(T &&initialValue)
Definition: qproperty.h:986
QPropertyChangeHandler< Functor > subscribe(Functor f)
Definition: qproperty.h:1121
void setValue(rvalue_ref t)
Definition: qproperty.h:1045
parameter_type operator*() const
Definition: qproperty.h:1019
QObjectBindableProperty(const QPropertyBinding< T > &binding)
Definition: qproperty.h:987
bool hasBinding() const
Definition: qproperty.h:1096
typename QPropertyData< T >::parameter_type parameter_type
Definition: qproperty.h:980
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &newBinding)
Definition: qproperty.h:1068
bool setBinding(const QUntypedPropertyBinding &newBinding)
Definition: qproperty.h:1075
QPropertyBinding< T > takeBinding()
Definition: qproperty.h:1108
QObjectBindableProperty(const T &initialValue)
Definition: qproperty.h:985
QPropertyChangeHandler< Functor > onValueChanged(Functor f)
Definition: qproperty.h:1114
const QtPrivate::QPropertyBindingData & bindingData() const
Definition: qproperty.h:1135
The QObjectComputedProperty class is a template class to help port old properties to the bindable pro...
Definition: qproperty.h:1204
constexpr bool hasBinding() const
Definition: qproperty.h:1247
QPropertyChangeHandler< Functor > onValueChanged(Functor f)
Definition: qproperty.h:1250
QPropertyChangeHandler< Functor > subscribe(Functor f)
Definition: qproperty.h:1257
QObjectComputedProperty()=default
std::conditional_t< QTypeTraits::is_dereferenceable_v< T >, parameter_type, void > operator->() const
Definition: qproperty.h:1229
QtPrivate::QPropertyBindingData & bindingData() const
Definition: qproperty.h:1271
parameter_type operator*() const
Definition: qproperty.h:1237
parameter_type value() const
Definition: qproperty.h:1222
QPropertyNotifier addNotifier(Functor f)
Definition: qproperty.h:1265
QPropertyBinding< T > takeBinding()
Definition: qproperty.h:923
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &newBinding)
Definition: qproperty.h:890
bool hasBinding() const
Definition: qproperty.h:913
QPropertyAlias< T > & operator=(const T &newValue)
Definition: qproperty.h:884
bool setBinding(const QUntypedPropertyBinding &newBinding)
Definition: qproperty.h:895
QPropertyAlias(Property *property)
Definition: qproperty.h:844
QPropertyAlias(const QBindable< T > &property)
Definition: qproperty.h:860
QPropertyChangeHandler< Functor > onValueChanged(Functor f)
Definition: qproperty.h:929
void setValue(const T &newValue)
Definition: qproperty.h:878
QPropertyAlias(QProperty< T > *property)
Definition: qproperty.h:835
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:902
QPropertyNotifier addNotifier(Functor f)
Definition: qproperty.h:941
T value() const
Definition: qproperty.h:868
QPropertyAlias(QPropertyAlias< T > *alias)
Definition: qproperty.h:852
QPropertyChangeHandler< Functor > subscribe(Functor f)
Definition: qproperty.h:935
QPropertyBinding< T > binding() const
Definition: qproperty.h:918
bool isValid() const
Definition: qproperty.h:946
bool hasError() const
Definition: qproperty.h:159
QPropertyBinding(const QUntypedPropertyBinding &binding)
Definition: qproperty.h:215
QPropertyBinding()=default
QPropertyBinding(Functor &&f, const QPropertyBindingSourceLocation &location)
Definition: qproperty.h:209
The QPropertyChangeHandler class controls the lifecycle of change callback installed on a QProperty.
Definition: qproperty.h:297
QPropertyChangeHandler(Functor handler)
Definition: qproperty.h:300
QPropertyChangeHandler(const Property &property, Functor handler)
Definition: qproperty.h:310
The QPropertyData class is a helper class for properties with automatic property bindings.
Definition: qproperty.h:85
QPropertyData(rvalue_ref t)
Definition: qproperty.h:101
typename std::conditional_t< UseReferences, T &&, DisableRValueRefs > rvalue_ref
Definition: qproperty.h:95
static constexpr bool UseReferences
Definition: qproperty.h:91
std::conditional_t< UseReferences, const T &, T > parameter_type
Definition: qproperty.h:94
void setValueBypassingBindings(rvalue_ref v)
Definition: qproperty.h:106
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:97
parameter_type valueBypassingBindings() const
Definition: qproperty.h:104
void setValueBypassingBindings(parameter_type v)
Definition: qproperty.h:105
QPropertyData()=default
QPropertyData(parameter_type t)
Definition: qproperty.h:100
~QPropertyData()=default
The QProperty class is a template class that enables automatic property bindings.
Definition: qproperty.h:350
QPropertyBinding< T > takeBinding()
Definition: qproperty.h:476
QProperty(const QPropertyBinding< T > &binding)
Definition: qproperty.h:370
QPropertyChangeHandler< Functor > subscribe(Functor f)
Definition: qproperty.h:489
QPropertyChangeHandler< Functor > onValueChanged(Functor f)
Definition: qproperty.h:482
QProperty< T > & operator=(rvalue_ref newValue)
Definition: qproperty.h:431
QProperty(rvalue_ref initialValue)
Definition: qproperty.h:369
const QtPrivate::QPropertyBindingData & bindingData() const
Definition: qproperty.h:503
bool hasBinding() const
Definition: qproperty.h:469
bool setBinding(const QUntypedPropertyBinding &newBinding)
Definition: qproperty.h:448
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:375
QPropertyBinding< T > binding() const
Definition: qproperty.h:471
parameter_type value() const
Definition: qproperty.h:385
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &newBinding)
Definition: qproperty.h:443
void setValue(parameter_type newValue)
Definition: qproperty.h:422
void setValue(rvalue_ref newValue)
Definition: qproperty.h:413
QProperty()=default
QProperty< T > & operator=(parameter_type newValue)
Definition: qproperty.h:437
typename QPropertyData< T >::parameter_type parameter_type
Definition: qproperty.h:363
QPropertyNotifier addNotifier(Functor f)
Definition: qproperty.h:497
arrow_operator_result operator->() const
Definition: qproperty.h:391
~QProperty()=default
parameter_type operator*() const
Definition: qproperty.h:403
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:458
QProperty(parameter_type initialValue)
Definition: qproperty.h:368
The QPropertyNotifier class controls the lifecycle of change callback installed on a QProperty.
Definition: qproperty.h:322
QPropertyNotifier()=default
QPropertyNotifier(Functor handler)
Definition: qproperty.h:327
QPropertyNotifier(const Property &property, Functor handler)
Definition: qproperty.h:337
QUntypedPropertyData * aliasData
Definition: qproperty.h:262
void(*)(QPropertyObserver *, QUntypedPropertyData *) ChangeHandler
Definition: qproperty.h:244
ChangeHandler changeHandler
Definition: qproperty.h:261
QPropertyBindingPrivate * binding
Definition: qproperty.h:260
void setSource(const Property &property)
Definition: qproperty.h:275
QUntypedPropertyData * aliasedProperty() const
Definition: qproperty.h:283
constexpr QPropertyObserver()=default
The QString class provides a Unicode character string.
Definition: qstring.h:388
QUntypedBindable is a uniform interface over bindable properties like QProperty<T> and QObjectBindabl...
Definition: qproperty.h:624
QUntypedPropertyBinding binding() const
Definition: qproperty.h:699
QUntypedPropertyBinding makeBinding(const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
Definition: qproperty.h:645
bool hasBinding() const
Definition: qproperty.h:729
QMetaType metaType() const
Definition: qproperty.h:734
const QtPrivate::QBindableInterface * iface
Definition: qproperty.h:628
QPropertyChangeHandler< Functor > subscribe(Functor f) const
Definition: qproperty.h:685
QUntypedPropertyBinding takeBinding()
Definition: qproperty.h:650
bool isBindable() const
Definition: qproperty.h:642
bool isValid() const
Definition: qproperty.h:641
bool setBinding(const QUntypedPropertyBinding &binding)
Definition: qproperty.h:710
bool isReadOnly() const
Definition: qproperty.h:643
QUntypedBindable(Property *p)
Definition: qproperty.h:636
QPropertyNotifier addNotifier(Functor f)
Definition: qproperty.h:692
constexpr QUntypedBindable(QUntypedPropertyData *d, const QtPrivate::QBindableInterface *i)
Definition: qproperty.h:629
QPropertyChangeHandler< Functor > onValueChanged(Functor f) const
Definition: qproperty.h:677
constexpr QUntypedBindable()=default
void observe(QPropertyObserver *observer) const
Definition: qproperty.h:665
QMetaType valueMetaType() const
Definition: qproperty.cpp:426
QUntypedPropertyBinding(QMetaType metaType, Functor &&f, const QPropertyBindingSourceLocation &location)
Definition: qproperty.h:177
static constexpr QBindableInterface iface
Definition: qproperty.h:554
QUntypedPropertyBinding setBinding(const QUntypedPropertyBinding &newBinding, QUntypedPropertyData *propertyDataPtr, QPropertyObserverCallback staticObserverCallback=nullptr, QPropertyBindingWrapper bindingWrapper=nullptr)
Definition: qproperty.cpp:445
QPropertyBindingPrivate * binding() const
#define T(x)
Definition: main.cpp:42
auto it unsigned count const
Definition: hb-iter.hh:848
short next
Definition: keywords.cpp:454
typename C::value_type value_type
Definition: qnamespace.h:55
Q_CORE_EXPORT void beginPropertyUpdateGroup()
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:222
Q_CORE_EXPORT void endPropertyUpdateGroup()
void printMetaTypeMismatch(QMetaType actual, QMetaType expected)
Definition: qproperty.cpp:2308
void printUnsuitableBindableWarning(QAnyStringView prefix, BindableWarnings::Reason reason)
Definition: qproperty.cpp:2289
constexpr size_t getOffset(size_t o)
constexpr BindingFunctionVTable bindingFunctionVTable
QString self
Definition: language.cpp:80
Definition: qfloat16.h:381
#define QString()
Definition: parse-defines.h:51
void
Definition: png.h:1080
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
EGLOutputLayerEXT EGLint EGLAttrib value
quint16 Offset
#define Q_DISABLE_COPY_MOVE(Class)
Definition: qglobal.h:519
unsigned int quint32
Definition: qglobal.h:288
size_t quintptr
Definition: qglobal.h:310
const QBindingStorage * qGetBindingStorage(const QObject *o)
Definition: qobject.h:513
GLenum type
Definition: qopengl.h:270
GLint location
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLfloat GLfloat f
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
Definition: qopenglext.h:2747
GLuint GLfloat * val
Definition: qopenglext.h:1513
GLdouble GLdouble t
[9]
Definition: qopenglext.h:243
GLuint64EXT * result
[6]
Definition: qopenglext.h:10932
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
#define QT_PROPERTY_DEFAULT_BINDING_LOCATION
Definition: qproperty.h:73
#define Q_ASSERT(cond)
Definition: qrandom.cpp:84
const char property[13]
Definition: qwizard.cpp:136
QStorageInfo storage
[1]
QSharedPointer< T > other(t)
[5]
header setValue("Host", "qt-project.org")
QMetaType(*)() GetMetaType
Definition: qproperty.h:535
void(*)(const QUntypedPropertyData *d, void *value) Getter
Definition: qproperty.h:529
QUntypedPropertyBinding(*)(QUntypedPropertyData *d, const QUntypedPropertyBinding &binding) BindingSetter
Definition: qproperty.h:532
void(*)(const QUntypedPropertyData *d, QPropertyObserver *observer) SetObserver
Definition: qproperty.h:534
void(*)(QUntypedPropertyData *d, const void *value) Setter
Definition: qproperty.h:530
QUntypedPropertyBinding(*)(const QUntypedPropertyData *d, const QPropertyBindingSourceLocation &location) MakeBinding
Definition: qproperty.h:533
QUntypedPropertyBinding(*)(const QUntypedPropertyData *d) BindingGetter
Definition: qproperty.h:531
static constexpr quintptr MetaTypeAccessorFlag
Definition: qproperty.h:544
Definition: main.cpp:38
Definition: moc.h:48