Search code examples
qtgradientqmlqprogressbar

Gradient for chunks in QProgressBar


Is it possible to set a common gradient for all QProgressBar chunks?

If use something like this:

QProgressBar::chunk:horizontal {
background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, 
                            stop: 0 green, 
                            stop: 1 white);
margin-right: 2px;    
width: 10px;
}

the result will be

http://labs.trolltech.com/blogs/wp-content/uploads/2007/06/progressbar_righttext.png

but I want to obtain a one gradient, stretched to all chunks. Like this:

http://labs.trolltech.com/blogs/wp-content/uploads/2007/06/progressbar_nochunk.png

divided onto chunks.

Thanks for all!


Solution

  • You cannot achieve what you want with the existing stylesheet properties. You could however subclass QProgressBar and reimplement the paint in order to get the appearance you wish.