qt model view 编程总结

看不见的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.

 

 

 

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值