达到的效果
QT 重写QStyledItemDelegate类实现item中的data数据显示
item数据正常添加
QT 重写QStyledItemDelegate类实现item中的data数据显示
关键的一行代码
QT 重写QStyledItemDelegate类实现item中的data数据显示

在MyItemDrawer中需要重写两个函数
1、void MyItemDrawer::paint(QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex & index) const

留出边框
QT 重写QStyledItemDelegate类实现item中的data数据显示
QRect中的adjust函数详情可查看转载的博客

图片显示
QT 重写QStyledItemDelegate类实现item中的data数据显示
名字显示
QT 重写QStyledItemDelegate类实现item中的data数据显示
电话显示
QT 重写QStyledItemDelegate类实现item中的data数据显示

2、QSize MyItemDrawer::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
QT 重写QStyledItemDelegate类实现item中的data数据显示

相关文章:

  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-04-12
  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-01
  • 2021-07-12
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
相关资源
相似解决方案