qt model view 程式設計總結

weixin_34162629發表於2015-04-24

看不見的root的 QModelIndex() 是 無效的

list 和table 的index 函式中的parent引數就只要 root QModelIndex 就可以,因為沒有層級概念

 

  • Model indexes give views and delegates information about the location of items provided by models in a way that is independent of any underlying data structures.
  • Items are referred to by their row and column numbers, and by the model index of their parent items.
  • Model indexes are constructed by models at the request of other components, such as views and delegates.
  • If a valid model index is specified for the parent item when an index is requested using index(), the index returned refers to an item beneath that parent item in the model. The index obtained refers to a child of that item.
  • If an invalid model index is specified for the parent item when an index is requested using index(), the index returned refers to a top-level item in the model.
  • The role distinguishes between the different kinds of data associated with an item.

 

  • The dimensions of a model can be found using rowCount() and columnCount(). These functions generally require a parent model index to be specified.
  • Model indexes are used to access items in the model. The row, column, and parent model index are needed to specify the item.
  • To access top-level items in a model, specify a null model index as the parent index with QModelIndex().
  • Items contain data for different roles. To obtain the data for a particular role, both the model index and the role must be supplied to the model.

 

 

 

 

相關文章