このページでは

QRangeModelAdapter::DataReference Struct

struct QRangeModelAdapter::DataReference

DataReference は、QRangeModel 内の項目をラップする参照ラッパーです。詳細...

この構造体はテクノロジープレビュー段階にあり、変更される可能性があります。

この構造体は Qt 6.11 で導入されました。

パブリック型

パブリック関数

DataReference(const QModelIndex &index)
DataReference(const QRangeModelAdapter<Range, Protocol, Model>::DataReference &other)
DataReference(QRangeModelAdapter<Range, Protocol, Model>::DataReference &&other)
~DataReference()
QRangeModelAdapter<Range, Protocol, Model>::DataReference::const_value_type get() const
bool isValid() const
operator QRangeModelAdapter<Range, Protocol, Model>::DataReference::const_value_type() const
QRangeModelAdapter<Range, Protocol, Model>::DataReference::pointer operator->() const
QRangeModelAdapter<Range, Protocol, Model>::DataReference &operator=(QRangeModelAdapter<Range, Protocol, Model>::DataReference &&other)
QRangeModelAdapter<Range, Protocol, Model>::DataReference &operator=(QRangeModelAdapter<Range, Protocol, Model>::DataReference::value_type &&value)
QRangeModelAdapter<Range, Protocol, Model>::DataReference &operator=(const QRangeModelAdapter<Range, Protocol, Model>::DataReference &other)
QRangeModelAdapter<Range, Protocol, Model>::DataReference &operator=(const QRangeModelAdapter<Range, Protocol, Model>::DataReference::value_type &value)

詳細な説明

at() の非 const オーバーロード、添え字operator[] 、または非 constiterator の逆参照を使用してモデル内の項目にアクセスすると、モデル内の項目をラップした DataReference ラッパーが返されます。

その参照ラッパーに値を代入すると、QAbstractItemModel API を使用してモデル内のデータが変更されます。

adapter[0] = newValue;

値自体の const バージョンには、get() または演算子 ->() を使用してアクセスできます。

QRangeModelAdapter adapter(QList<Gadget>{ ~~~ });
auto value = adapter[0]->value();
// adapter[0]->setValue(); // not allowed - would not emit dataChanged()

std::reference_wrapper とは対照的に、ある DataReference を別の DataReference に代入しても、参照は再バインドされず、コピーセマンティクスを使用して値が設定されます。

adapter[0] = adapter[1]; // items at row 0 and row 1 now have the same value

「 RowReference 」および「ConstRowReference 」も参照してください 。

メンバ型のドキュメント

[alias] DataReference::const_value_type

基になる範囲に格納されている項目のconst型の別名です。モデル内の異なる列が異なる型を持っている場合、これはconst QVariant の別名となります。

[alias] DataReference::pointer

operator->() によって返されるポインタ型の別名。

[alias] DataReference::value_type

基になる範囲に格納されている項目の型の別名です。モデル内の異なる列が異なる型を持っている場合、これは `QVariant` の別名となります。

メンバ関数のドキュメント

[explicit noexcept] DataReference::DataReference(const QModelIndex &index)

index にある項目に対して、DataReference ラッパーを生成します。

[default] DataReference::DataReference(const QRangeModelAdapter<Range, Protocol, Model>::DataReference &other)

other のコピーを作成します。

[default] DataReference::DataReference(QRangeModelAdapter<Range, Protocol, Model>::DataReference &&other)

other から移動して、DataReference を生成します。

[default] DataReference::~DataReference()

DataReference のインスタンスを破棄します。

QRangeModelAdapter<Range, Protocol, Model>::DataReference::const_value_type DataReference::get() const

DataReference::operator QRangeModelAdapter<Range, Protocol, Model>::DataReference::const_value_type() const

このDataReference が参照する項目の値を、const値として返します。

bool DataReference::isValid() const

このDataReference が有効なモデルインデックスを指している場合、trueを返します。

QRangeModelAdapter<Range, Protocol, Model>::DataReference::pointer DataReference::operator->() const

このDataReference が指す値へのポインタを返します。

QRangeModelAdapter<Range, Protocol, Model>::DataReference &DataReference::operator=(QRangeModelAdapter<Range, Protocol, Model>::DataReference &&other)

値への参照をother 分だけ、このラッパーが参照する値の中に移動します。

QRangeModelAdapter<Range, Protocol, Model>::DataReference &DataReference::operator=(QRangeModelAdapter<Range, Protocol, Model>::DataReference::value_type &&value)

value を基となるモデル項目に割り当てます。

QRangeModelAdapter<Range, Protocol, Model>::DataReference &DataReference::operator=(const QRangeModelAdapter<Range, Protocol, Model>::DataReference &other)

other が参照する項目の値を、このラッパーが参照する値に代入します。

QRangeModelAdapter<Range, Protocol, Model>::DataReference &DataReference::operator=(const QRangeModelAdapter<Range, Protocol, Model>::DataReference::value_type &value)

基となるモデル項目に「value 」を割り当てます。

© 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.