继承Q stylishItemDelegate的进度条控制项绘制
发布时间
阅读量:
阅读量
The WidgetDelegate class is developed by inheriting from QStylerItemDelegate. The drawing process is implemented within the paint() function.
void WidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.column() == 1) {
int progress = index.data().toInt();
QStyle Option ProgressBar progressBar Option;
设置该ProgressBar Option 的矩形属性与给定选项的矩形属性相同;
将该ProgressBar Option 的最小值设为 0;
将该ProgressBar Option 的最大值设定为 100;
将当前进度赋值给该ProgressBar Option 的进度字段;
将进度转换为字符串并添加百分号作为文本设置;
显示文本标记设为 true;
QApplication::style()->绘制指定类型的控制条目到给定的画图
全部评论 (0)
还没有任何评论哟~
