source: trunk/doc/src/snippets/widgetdelegate.cpp@ 244

Last change on this file since 244 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 833 bytes
Line 
1
2#include <QtGui>
3
4#include "widgetdelegate.h"
5
6//![0]
7void WidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
8 const QModelIndex &index) const
9{
10 if (index.column() == 1) {
11 int progress = index.data().toInt();
12
13 QStyleOptionProgressBar progressBarOption;
14 progressBarOption.rect = option.rect;
15 progressBarOption.minimum = 0;
16 progressBarOption.maximum = 100;
17 progressBarOption.progress = progress;
18 progressBarOption.text = QString::number(progress) + "%";
19 progressBarOption.textVisible = true;
20
21 QApplication::style()->drawControl(QStyle::CE_ProgressBar,
22 &progressBarOption, painter);
23 } else
24 QStyledItemDelegate::paint(painter, option, index);
25
26//![0]
27}
Note: See TracBrowser for help on using the repository browser.