void ATCMprogressbar::paintEvent(QPaintEvent * e) { Q_UNUSED( e ); QPainter painter(this); QPalette palette = this->palette(); QStyleOptionProgressBar option; option.init(this); QStyleOptionProgressBarV2 opt(option); /* bar color */ palette.setColor(QPalette::Button, m_barColor); /* border color */ palette.setColor(QPalette::Foreground, m_bordercolor); /* bg color */ palette.setColor(QPalette::Background, m_bgcolor); #ifdef TARGET_ARM if (m_viewstatus) { /* draw the background color in funtion of the status */ palette.setColor(QPalette::Foreground, Qt::red); if (m_status & STATUS_OK) palette.setColor(QPalette::Foreground, Qt::green); else if (m_status & (STATUS_BUSY_R | STATUS_BUSY_W)) palette.setColor(QPalette::Foreground, Qt::yellow); else if (m_status & (STATUS_FAIL_W | STATUS_ERR)) palette.setColor(QPalette::Foreground, Qt::red); else palette.setColor(QPalette::Foreground, Qt::gray); } #endif opt.palette = palette; _diameter_ = m_borderradius; _penWidth_ = m_borderwidth; if (m_apparence == QFrame::Raised) { opt.state = QStyle::State_Raised; } else if (m_apparence == QFrame::Sunken) { opt.state = QStyle::State_Sunken; } opt.orientation = QProgressBar::orientation(); opt.minimum = QProgressBar::minimum(); opt.maximum = QProgressBar::maximum(); opt.progress = QProgressBar::value(); style()->drawControl(QStyle::CE_ProgressBar, &opt, &painter); }
static QStyleOptionProgressBar getStyleOption(const Q3ProgressBar *pb) { QStyleOptionProgressBar opt; opt.init(pb); opt.rect = pb->contentsRect(); opt.minimum = 0; opt.maximum = pb->totalSteps(); opt.progress = pb->progress(); if (pb->centerIndicator()) opt.textAlignment = Qt::AlignCenter; else opt.textAlignment = Qt::AlignAuto; opt.textVisible = pb->percentageVisible(); opt.text = pb->progressString(); return opt; }