什么是QStyledItemDelegate
在介绍之前我们看一下 view / model 的示意图,之中代理就是delegate ,从图中我们可以看到它有2个作用
1、显示
2、编辑
qt 官方介绍:
When displaying data from models in Qt item views, e.g., a QTableView, the individual items are drawn by a delegate. Also, when an item is edited, it provides an editor widget, which is placed on top of the item view while editing takes place. QStyledItemDelegate is the default delegate for all Qt item views, and is installed upon them when they are created.
The QStyledItemDelegate class is one of the Model/View Classes and is part of Qt's model/view framework. The delegate allows the display and editing of items to be developed independently from the model and view.
The data of items in models are assigned an ItemDataRole; each item can store a QVariant for each role. QStyledItemDelegate implements display and editing for the most common datatypes expected by users, including booleans, integers, and strings.
总结:
1.QStyledItemDelegate 是 view 的默认委托,单个Item由委托绘制