Cambiar el fondo de QProgressbar y la imagen fragmentada programáticamente

I need to change the background and chunk image of a QProgressBar element programatically. I already know that I can achieve this by applying a StyleSheet with a given image url during runtime. The problem in my case is that I can't use local files but rather have to download the file during runtime. Thus I must be able to set the background image of a QProgressBar using a QImage/QPixmap/QIcon (or any other appropriate) object without using a Stylesheet.

¿Es esto posible de alguna manera?

preguntado el 28 de mayo de 14 a las 13:05

Hi and Welcome to SO , What have you tried till now... ??? -

I ended up writing my own Progressbar with two given QPixmap objects (one for the background and one for the progress overlay). To achieve the correct look of the Widget, I had to override the paintEvent method of QWidget and paint the control myself. I will write an answer to my question with the belonging code later. -

1 Respuestas

This is correct answer to set styleSheet of QProgressBar:

 QString style=NULL;
style.append("QProgressBar{border: 0px solid grey;background-image:url("/UrlImage Background/abc.png");background-color:transparent;}");
style.append("QProgressBar::chunk {background:url("/UrlImage Background/chunkimage.png");}");

respondido 12 nov., 15:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.