【问题标题】:Associating a key with a row of QStandardItemModel将键与 QStandardItemModel 行关联
【发布时间】:2013-07-12 22:52:34
【问题描述】:

我想知道如何将键与 QstandardItemModel 的条目相关联。这将帮助我检索条目的行。

【问题讨论】:

    标签: c++ qt model-view qstandarditemmodel


    【解决方案1】:

    http://doc-snapshot.qt-project.org/4.8/qstandarditemmodel.html#details

    数据使用的所有访问器方法:

    http://doc-snapshot.qt-project.org/4.8/qmodelindex.html

    QModelIndex

    http://doc-snapshot.qt-project.org/4.8/model-view-programming.html#model-indexes

    http://doc-snapshot.qt-project.org/4.8/qpersistentmodelindex.html

    QPersistentModelIndex 类用于定位数据模型中的数据。

    QPersistentModelIndex 是一个模型索引,可以由应用程序存储,然后用于访问模型中的信息。与 QModelIndex 类不同,存储 QPersistentModelIndex 是安全的,因为模型将确保对项目的引用将继续有效,只要它们可以被模型访问。

    最好在使用持久模型索引之前检查它们是否有效。

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2015-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-08
      • 1970-01-01
      • 1970-01-01
      • 2012-11-24
      相关资源
      最近更新 更多