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

qt model view 编程总结的更多相关文章

  1. Qt Model/View(官方翻译,图文并茂)

    http://doc.trolltech.com/main-snapshot/model-view-programming.html 介绍 Qt 4推出了一组新的item view类,它们使用mode ...

  2. (转)Qt Model/View 学习笔记 (五)——View 类

    Qt Model/View 学习笔记 (五) View 类 概念 在model/view架构中,view从model中获得数据项然后显示给用户.数据显示的方式不必与model提供的表示方式相同,可以与 ...

  3. (转)Qt Model/View 学习笔记 (一)——Qt Model/View模式简介

    Qt Model/View模式简介 Qt 4推出了一组新的item view类,它们使用model/view结构来管理数据与表示层的关系.这种结构带来的 功能上的分离给了开发人员更大的弹性来定制数据项 ...

  4. (转)Qt Model/View 学习笔记 (七)——Delegate类

    Qt Model/View 学习笔记 (七) Delegate  类 概念 与MVC模式不同,model/view结构没有用于与用户交互的完全独立的组件.一般来讲, view负责把数据展示 给用户,也 ...

  5. (转)Qt Model/View 学习笔记 (二)——Qt Model/View模式举例

    Qt Model/View模式举例 Qt提供了两个标准的models:QStandardItemModel和QDirModel.QStandardItemModel是一个多用途的model,可用于表示 ...

  6. (一) Qt Model/View 的简单说明

    (一) Qt Model/View 的简单说明 .预定义模型 (二)使用预定义模型 QstringListModel例子 (三)使用预定义模型QDirModel的例子 (四)Qt实现自定义模型基于QA ...

  7. qt model/view/delegate

    Qt Model/View理解(一)---构造model https://blog.csdn.net/weixin_42303052/article/details/89233887 Qt Model ...

  8. Qt Model/View 的简单说明

    目录: (一) Qt Model/View 的简单说明 .预定义模型 (二)使用预定义模型 QstringListModel例子 (三)使用预定义模型QDirModel的例子 (四)Qt实现自定义模型 ...

  9. Qt Model/View(模型/视图)结构(无师自通)

    Model/View(模型/视图)结构是 Qt 中用界面组件显示与编辑数据的一种结构,视图(View)是显示和编辑数据的界面组件,模型(Model)是视图与原始数据之间的接口. GUI 应用程序的一个 ...

随机推荐

  1. action(四)

    void ActionDelayTime::onEnter() { ActionsDemo::onEnter(); alignSpritesLeft(); CCActionInterval* move ...

  2. Python @ddt.file_data() 为.yml 文件实例

    一,创建login.yml 文件(以登录接口为例) 1,创建 login.yml 文件,内容如下图: 打印login.yml 文件,代码及显示效果如下: 代码: import yaml,jsonf = ...

  3. swift 类型.

    swift 类型 变量声明 用let来声明常量,用var来声明变量 可以在一行中声明多个常量或者多个变量,用逗号隔开 var x = 0.0, y = 0.0, z = 0.0 类型安全 Swift ...

  4. TIM—高级定时器

    本章参考资料:< STM32F4xx 参考手册>.< STM32F4xx 规格书>.库帮助文档< stm32f4xx_dsp_stdperiph_lib_um.chm&g ...

  5. FreeRtos——空闲任务与空闲任务钩子函数

    以下基础知识转载自正点原子PDF资料. 前面例子 中创建的任务大部份时间都处于阻塞态.这种状态下所有的任务都不可运行,所以也不能被调度器选中.但处理器总是需要代码来执行——所以至少要有一个任务处于运行 ...

  6. Web 服务器被配置为不列出此目录的内容

    在Web.configue文件里,会多出来部分代码,应该是允许浏览目录: <?xml version="1.0" encoding="utf-8"?> ...

  7. Setup Factory 读取安装包的配置文件

    result = INIFile.GetValue(SessionVar.Expand("%SourceFolder%\\set.ini"), "set", & ...

  8. PHP——内测:联系人管理

    要求见文件-内测:联系人管理.pdf 数据库为mycontacts 表格为contacts,groups 表格内容为: zhuye.php <!DOCTYPE html PUBLIC " ...

  9. asp.net 列表样式

    找了好一段时间,找到一个不错的文章列表样式,留起来备用 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...

  10. php7 扩展模块添加

    php 扩展模块添加   1. 新增安装扩展模块的位置 [root@node_22 ~]# ls /usr/local/php7/lib/php/extensions/no-debug-non-zts ...