void QProgressBar::drawContents( QPainter *p )
{
const QRect bar = contentsRect();
QPixmap pm( bar.size() );
QPainter paint( &pm );
const QPixmap * bgPixmap = backgroundPixmap();
QBrush fbrush = ( bgPixmap ? QBrush( backgroundColor(), *bgPixmap ) :
QBrush( backgroundColor() ) );
if ( bgPixmap && !isTopLevel() && (backgroundOrigin() != WidgetOrigin) )
paint.setBrushOrigin( -x(), -y() );
paint.fillRect( bar, fbrush );
paint.setFont( p->font() );
QStyle::SFlags flags = QStyle::Style_Default;
if (isEnabled())
flags |= QStyle::Style_Enabled;
if (hasFocus())
flags |= QStyle::Style_HasFocus;
style().drawControl(QStyle::CE_ProgressBarGroove, &paint, this,
QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarGroove, this), this ),
colorGroup(), flags);
style().drawControl(QStyle::CE_ProgressBarContents, &paint, this,
QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarContents, this), this ),
colorGroup(), flags);
if (percentageVisible())
style().drawControl(QStyle::CE_ProgressBarLabel, &paint, this,
QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarLabel, this), this ),
colorGroup(), flags);
paint.end();
p->drawPixmap( bar.x(), bar.y(), pm );
}