继承QStyledItemDelegate 进度条控件重绘
来源:互联网 发布:linux dd命令拷贝硬盘 编辑:程序博客网 时间:2024/05/29 14:48
We create the WidgetDelegate class, which inherits from QStyledItemDelegate. We do the drawing in the paint() function:
void WidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.column() == 1) {
int progress = index.data().toInt();
QStyleOptionProgressBar progressBarOption;
progressBarOption.rect = option.rect;
progressBarOption.minimum = 0;
progressBarOption.maximum = 100;
progressBarOption.progress = progress;
progressBarOption.text = QString::number(progress) + "%";
progressBarOption.textVisible = true;
QApplication::style()->drawControl(QStyle::CE_ProgressBar,
&progressBarOption, painter);
} else
QStyledItemDelegate::paint(painter, option, index);
void WidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.column() == 1) {
int progress = index.data().toInt();
QStyleOptionProgressBar progressBarOption;
progressBarOption.rect = option.rect;
progressBarOption.minimum = 0;
progressBarOption.maximum = 100;
progressBarOption.progress = progress;
progressBarOption.text = QString::number(progress) + "%";
progressBarOption.textVisible = true;
QApplication::style()->drawControl(QStyle::CE_ProgressBar,
&progressBarOption, painter);
} else
QStyledItemDelegate::paint(painter, option, index);
0 0
- 继承QStyledItemDelegate 进度条控件重绘
- 重绘进度条控件
- QStyledItemDelegate
- 重绘-下载进度条(setNeedsDisplay)
- 自定义View:重绘进度条
- 进度条重绘(CProgressCtrl)
- 关于QStyledItemDelegate在tableview控件中的使用心得
- 继承与重绘
- 进度条控件
- 进度条控件
- 进度条控件
- 控件进度条
- 控件.重绘 setredraw
- 禁止控件重绘
- android控件重绘
- 重绘静态控件
- 重绘编辑控件
- 重绘按钮控件
- MFC中如何将焦点设置到指定控件上
- linux安装gcc-arm-none-eabi
- Andriod测试类和测试内容
- Android.mk 分析:./frameworks/base/core/res/Android.mk
- repo & git 的使用方法
- 继承QStyledItemDelegate 进度条控件重绘
- gtest使用方法
- POJ2236
- C# 让程序默认以管理员运行
- sdfs
- repo & git 的使用方法
- Deep Learning——CNN(Convolution Neural Network)
- Android 调试之 Log和LogCat的详解
- Struct和Class的不同