{
Q_UNUSED(pe);
QRect pb_rect
= this
->geometry
();
int value;
int max;
int margin = 0;
int altezza_nor;
max = this->maximum();
value = this->value();
altezza_nor = (value*pb_rect.height())/max;
painter.
setRenderHint(QPainter::Antialiasing);
m_shadow
= QColor(19,
79,
236);
pb_color
= QColor(139,
213,
252);
gradcolorH1 = m_shadow;
gradcolorH2 = pb_color;
//outline
painter.
setPen(QPen(QBrush(Qt
::black), pb_rect.
width()));
outline.addRoundRect(0, 0, pb_rect.width(), pb_rect.height(), 0, 0);
painter.setOpacity(1);
painter.drawPath(outline);
// gradient
QLinearGradient gradient
(margin, pb_rect.
height() - altezza_nor
+ margin, pb_rect.
width() - margin, pb_rect.
height() -margin
);
gradient.setColorAt(0.0, pb_color);
gradient.setColorAt(1.0, m_shadow);
painter.setBrush(brush);
painter.setOpacity(1);
painter.drawRoundRect(margin, pb_rect.height() - altezza_nor + margin, pb_rect.width() - margin, pb_rect.height() -margin,0,0);//pb_rect.height() - 2, 0, 0);
// gradient
QLinearGradient gradientH
(0,
(pb_rect.
height() - altezza_nor
)/2, pb_rect.
width(),
(pb_rect.
height() - altezza_nor
)/2);
gradientH.setColorAt(0.0, gradcolorH1);
gradientH.setColorAt(0.2, gradcolorH2);
gradientH.setColorAt(0.8, gradcolorH2);
gradientH.setColorAt(1.0, gradcolorH1);
painter.setBrush(brushH);
painter.setOpacity(0.3);
painter.drawRoundRect(margin, pb_rect.height() - altezza_nor, pb_rect.width() - margin, pb_rect.height() -margin,0,0);//pb_rect.height() - 2, 0, 0);
}
void myProgressBar::paintEvent(QPaintEvent *pe)
{
Q_UNUSED(pe);
QRect pb_rect = this->geometry();
QColor pb_color;
QColor m_shadow;
QColor gradcolorH1;
QColor gradcolorH2;
int value;
int max;
int margin = 0;
int altezza_nor;
max = this->maximum();
value = this->value();
altezza_nor = (value*pb_rect.height())/max;
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
m_shadow = QColor(19, 79, 236);
pb_color = QColor(139, 213, 252);
gradcolorH1 = m_shadow;
gradcolorH2 = pb_color;
//outline
painter.setPen(QPen(QBrush(Qt::black), pb_rect.width()));
QPainterPath outline;
outline.addRoundRect(0, 0, pb_rect.width(), pb_rect.height(), 0, 0);
painter.setOpacity(1);
painter.drawPath(outline);
// gradient
QLinearGradient gradient(margin, pb_rect.height() - altezza_nor + margin, pb_rect.width() - margin, pb_rect.height() -margin);
gradient.setColorAt(0.0, pb_color);
gradient.setColorAt(1.0, m_shadow);
QBrush brush(gradient);
painter.setBrush(brush);
painter.setPen(QPen(QBrush(pb_color), 5.0));
painter.setOpacity(1);
painter.drawRoundRect(margin, pb_rect.height() - altezza_nor + margin, pb_rect.width() - margin, pb_rect.height() -margin,0,0);//pb_rect.height() - 2, 0, 0);
// gradient
QLinearGradient gradientH(0, (pb_rect.height() - altezza_nor)/2, pb_rect.width(), (pb_rect.height() - altezza_nor)/2);
gradientH.setColorAt(0.0, gradcolorH1);
gradientH.setColorAt(0.2, gradcolorH2);
gradientH.setColorAt(0.8, gradcolorH2);
gradientH.setColorAt(1.0, gradcolorH1);
QBrush brushH(gradientH);
painter.setBrush(brushH);
painter.setOpacity(0.3);
painter.drawRoundRect(margin, pb_rect.height() - altezza_nor, pb_rect.width() - margin, pb_rect.height() -margin,0,0);//pb_rect.height() - 2, 0, 0);
}
To copy to clipboard, switch view to plain text mode
Bookmarks