Hi all. I wuold like to obtain a ProgressBar like this.
I think I have to apply a double linear gradient but I don't understand how I can.
Could you help me?
Thank you
Beppe
Printable View
Hi all. I wuold like to obtain a ProgressBar like this.
I think I have to apply a double linear gradient but I don't understand how I can.
Could you help me?
Thank you
Beppe
I guess for that you have to subclass QProgressBar and draw it yourself. I can't imagine that that is possible with style sheets.
In your paint method just draw the blue gradient and then the "transparent white" one (also see QPainter::CompositionMode).
is this one u want ....
QProgressBar::chunk {background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #C71585, stop: 1 white)
oh .. means like a 3d progressbar in 2d view ..? ..
With style sheet you only get that flat effect:
http://www.qtcentre.org/forum/attach...0&d=1241604162
But if you paint it yourself you could archeive a sort of 3d look, note the little shiny white on top and bottom in that kde 4 oxygen example
http://www.qtcentre.org/forum/attach...9&d=1241604162
This you can't do with style sheets.
Thank you guys.
I implemented the paint event of my class
this is the code
Code:
{ Q_UNUSED(pe); 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; gradcolorH1 = m_shadow; gradcolorH2 = pb_color; //outline 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); 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); }
I'm sure my code is not optimized. Any suggestion will be appreciated.
Thank you
Beppe