qt delegate委托 paint()方法
来源:互联网 发布:ipad办公 知乎 编辑:程序博客网 时间:2024/06/07 13:55
paint函数的作用是:绘制要在view中显示的数据。
获取到model中的数据后,我想改变显示样式,那么可用在painter函数中进行改变。
1.
获取model中的数据
index.model()->data( index );
2.
改变数据为自己想要的形式
例如,改变字体,改变颜色等。
改变字体:
QStyleOptionViewItem so = option;//因为option参数是const类型,不能直接修改option,所以,做一个同类型的拷贝,修改so参数。
so.palette = QPalette(Qt::red);
drawDisplay(painter,so,so.rect,str);
3.
显示数据
调用QItemDelegate类的DrawDisplay()函数。
option变量,此时就用到了。因为option的字体,text对齐方式等都已经修改为想要的样式,所以,将option传递给DrawDisplay()函数。
DrawDisplay()函数的作用就是,绘制要现实的数据。
按照option中的样式进行绘制要显示的text。
void QItemDelegate::drawDisplay ( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect, const QString & text )
Renders the item view text within the rectangle specified by rect using the given painter and style option.
作用:
绘制在view中显示的item的text,即绘制要在view中显示的文字,也就是item的内容。
- qt delegate委托 paint()方法
- qt 委托 paint() 显示数据
- qt 委托 delegate
- qt delegate createEditor()方法
- 委托(Delegate)
- 委托(Delegate)
- 委托(Delegate)
- 委托(Delegate)
- 委托(Delegate)
- 委托(Delegate)
- 委托(Delegate)
- 什么是委托(Delegate)
- 什么是委托(Delegate)
- 委托(Delegate)机制
- 委托(delegate)模式
- 委托(delegate)
- 委托(Delegate)
- 委托(Delegate)简介
- IOS对象关系映射(ORM)之coreData框架的学习——(一)基本使用
- 楔子
- JZOJ 3498【NOIP2013模拟联考14】图形变换
- Struts2国际化支持(中英文选择)
- SQL语句基础
- qt delegate委托 paint()方法
- UVA 10881 - Piotr's Ants(思维转换)
- 一些概念名称的来历札记
- 外链的表现形式有哪几种?
- 欢迎使用CSDN-markdown编辑器
- apple各种型号设备对应的Size Class
- javascript快速入门
- Unity 3D 控制物体上下左右均匀移动脚本
- 十一第二题