1.伙伴编辑模式
当用户激活标签的快捷键时,鼠标/键盘的焦点将会转移到它的伙伴窗口部件上
Qt对象只有QLabel标签对象才可以有伙伴窗口部件,也只有QLable对象具有快捷键时,伙伴关系才有效
2.QModelIndex
这个类用在被被QAbstractItemModel
派生的模型(item models)的索引。这个索引可以被用在item views,delegates,selection models,用这个索引可以定位项(item)在模型的什么位置。
模型可以通过函数QAbstractItemModel::createIndex()
创建一个新的QModelIndex
对象。使用QModelIndex构造函数构造一个无效的模型索引。
在模型中,一个索引来表示对应的一个项(item),每个索引都包含有确定对应项的位置的所有信息。通过给定的row和column可以确定一个索引,每个索引可能都包含一个父索引,用row(),column(),parent()这些函数获取相应的信息。模型中的每个顶级项目都是一个没有父索引的,正因为这个原因,parent()将会返回一个无效的索引,这个索引与无参构造函数QModelIndex()
构造的索引是等价的。
如果知道索引引用的是什么模型,用函数model() 返回模型类型
const QAbstractItemModel *QModelIndex::model() const;
/*Returns a pointer to the model containing the item that this index refers to.
A const pointer to the model is returned because calls to non-const functions of the model might invalidate the model index and possibly crash your application.*/1234
如果检查一个项是否有孩子索引,chiled() 函数可以实现。
QTreeWidgetItem *QTreeWidgetItem::child(int index) const;
/*Returns the item at the given index in the list of the item's children.*/
123
遍历索引级别相同的项,可使用sibling()函数
QModelIndex QModelIndex::sibling(int row, int column) const;
/*Returns the sibling(姊妹的意思) at row and column. If there is no sibling at this position, an invalid QModelIndex is returned.*/12
注意
模型索引(Model indexes)应该在用完后,把它及时清除。在调用更改模型的结构或删除项目的模型函数之后,不应该让索引保持有效。如果您需要在一段时间内使用一个模型索引,那么使用QPersistentModelIndex。
3.view是什么类型,和widget有什么区别
view时所控件的基类,
关于model/view的知识下面这篇介绍ok
http://blog.youkuaiyun.com/hahajing9/article/details/6090511
view和widget的区别
https://blog.youkuaiyun.com/bzhxuexi/article/details/9922595
4.movetoThread是什么意思
下面
http://blog.csdn.NET/chinabinlang/article/details/35988801