QItemDelegate 和 QStyledItemDelegate 有什么区别?

What is the difference between QItemDelegate and QStyledItemDelegate?

两者 类 都为模型中的数据项提供显示和编辑工具。 QStyledItemDelegate 较新,有关 QItemDelegate 的 Qt 文档指出:

Note that QStyledItemDelegate has taken over the job of drawing Qt's item views. We recommend the use of QStyledItemDelegate when creating new delegates.

我很困惑两者之间有什么区别以及为什么 QStyledItemDelegate 优于 QItemDelegate

QStyledItemDelegate documentation中所述,不同之处在于QStyledItemDelegate使用当前样式绘制其项目。

These two classes are independent alternatives to painting and providing editors for items in views. The difference between them is that QStyledItemDelegate uses the current style to paint its items. We therefore recommend using QStyledItemDelegate as the base class when implementing custom delegates or when working with Qt style sheets. The code required for either class should be equal unless the custom delegate needs to use the style for drawing.

请注意,此答案基于 Iuliu 和 Alex

的评论