QUntypedBindable Class
QUntypedBindable は、任意の型T の、QProperty\<T\> やQObjectBindableProperty といったバインド可能なプロパティに対して定義された統一インターフェースです。詳細...
| ヘッダー: | #include <QUntypedBindable> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| 以下のように: | Qt 6.0 |
| 継承元: |
パブリック関数
| QUntypedBindable() | |
| QUntypedBindable(Property *property) | |
| QPropertyNotifier | addNotifier(Functor f) |
| QUntypedPropertyBinding | binding() const |
| bool | hasBinding() const |
(since 6.1) bool | isReadOnly() const |
| bool | isValid() const |
| QUntypedPropertyBinding | makeBinding(const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) const |
(since 6.2) QMetaType | metaType() const |
| QPropertyChangeHandler<Functor> | onValueChanged(Functor f) const |
| bool | setBinding(const QUntypedPropertyBinding &binding) |
| QPropertyChangeHandler<Functor> | subscribe(Functor f) const |
(since 6.1) QUntypedPropertyBinding | takeBinding() |
詳細な説明
QUntypedBindable は、バインド可能なプロパティをラップするための、完全に型消去されたジェネリックインターフェースです。これを使用すると、プロパティの型を知らなくても、またそれがどのような種類のバインド可能なプロパティであるかを気にすることなく、プロパティとやり取りすることができます(例:QProperty やQObjectBindableProperty など)。 ほとんどのユースケースでは、QBindable<T>(プロパティの実装に対してジェネリックですが、型は固定されています)の使用が推奨されます。
メンバ関数のドキュメント
[constexpr noexcept default] QUntypedBindable::QUntypedBindable()
QUntypedBindable をデフォルトで生成します。これは無効な状態です。
isValid()も参照してください 。
template <typename Property> QUntypedBindable::QUntypedBindable(Property *property)
プロパティ `property` から `QUntypedBindable` を作成します。`Property` が `const` の場合、`QUntypedBindable` は読み取り専用になります。`property ` が `null` の場合、`QUntypedBindable` は無効になります。
isValid() およびisReadOnly()も参照してください 。
template <typename Functor> QPropertyNotifier QUntypedBindable::addNotifier(Functor f)
f を変更ハンドラとして登録します。基となるプロパティが変更されるたびに、返されたQPropertyNotifier とそのプロパティが存続している限り、f が呼び出されます。
このメソッドは、返されるオブジェクトがテンプレートではないため、場合によってはonValueChanged() よりも使いやすくなっています。そのため、例えばクラスのメンバとして保存するのが容易です。
onValueChanged() およびsubscribe()も参照してください 。
QUntypedPropertyBinding QUntypedBindable::binding() const
該当するプロパティのバインディングが存在する場合はそれを返し、存在しない場合はデフォルトで生成されたQUntypedPropertyBinding を返します。
setBinding() およびhasBinding()も参照してください 。
bool QUntypedBindable::hasBinding() const
基になるプロパティにバインディングがある場合、true を返します。
[since 6.1] bool QUntypedBindable::isReadOnly() const
QUntypedBindable が読み取り専用である場合、true を返します。
この関数は Qt 6.1 で導入されました。
bool QUntypedBindable::isValid() const
QUntypedBindable が有効な場合、true を返します。無効なQUntypedBindable に対して呼び出されたメソッドは、特に断りがない限り、通常は何も効果をもたらしません。
QUntypedPropertyBinding QUntypedBindable::makeBinding(const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
指定されたソースlocation を使用して、基になるプロパティの値を返すバインディングを作成します。
[since 6.2] QMetaType QUntypedBindable::metaType() const
QUntypedBindable が作成されたプロパティのメタタイプを返します。バインダブルが無効な場合、無効なメタタイプが返されます。
この関数は Qt 6.2 で導入されました。
isValid() およびQUntypedPropertyBinding::valueMetaType()も参照してください 。
template <typename Functor> QPropertyChangeHandler<Functor> QUntypedBindable::onValueChanged(Functor f) const
f を変更ハンドラとして登録します。基になるプロパティが変更されるたびに、返されたQPropertyChangeHandler とそのプロパティが存続している限り、f が呼び出されます。値が変更されるたびに、コンテキストに応じて、ハンドラが即座に呼び出されるか、または呼び出しが延期されます。
QProperty::onValueChanged() およびsubscribe()も参照してください 。
bool QUntypedBindable::setBinding(const QUntypedPropertyBinding &binding)
基になるプロパティのバインディングを `binding` に設定します。QUntypedBindable が読み取り専用である場合、null である場合、または `binding` の型が基になるプロパティの型と一致しない場合は、この操作は効果を持ちません。
バインディングの設定に成功した場合、true を返します。
binding() およびQUntypedPropertyBinding::valueMetaType()も参照してください 。
template <typename Functor> QPropertyChangeHandler<Functor> QUntypedBindable::subscribe(Functor f) const
f の呼び出しに続いてonValueChanged(f) が実行されるのと同じ動作をします。
onValueChanged()も参照してください 。
[since 6.1] QUntypedPropertyBinding QUntypedBindable::takeBinding()
プロパティから現在設定されているバインディングを削除し、そのプロパティを返します。バインディングが設定されていない場合は、デフォルトコンストラクタで生成されたQUntypedPropertyBinding を返します。
この関数は Qt 6.1 で導入されました。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.