Qt之QStyledItemDelegate类

Posted 唯一诺

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Qt之QStyledItemDelegate类相关的知识,希望对你有一定的参考价值。

主要用于自定义项的display和编辑;

通常有两个重载函数:

1     // 决定该单元格的推荐大小
2     virtual QSize  sizeHint(const QStyleOptionViewItem & option,
3         const QModelIndex & index) const;
4 
5     // 决定如何绘图
6     virtual void  paint(QPainter * painter,
7         const QStyleOptionViewItem & option,
8         const QModelIndex & index) const;

 

以上是关于Qt之QStyledItemDelegate类的主要内容,如果未能解决你的问题,请参考以下文章

Qt入门教程数据模型篇QStyledItemDelegate样式代理类

Qt表格中的自定义编辑组件---------------自定义代理QStyledItemDelegate

Qt之模型/视图(自定义按钮)

Qt5 子类化 QStyledItemDelegate 格式

Qt。如果我在 QStyledItemDelegate 中定义了 paint() 方法,则方法 displayText() 不起作用

QStyledItemDelegate - updateEditorGeometry 如何工作?