0

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.

Is this somehow possible?

tobmuell
  • 1
  • 1
  • Hi and Welcome to SO , What have you tried till now... ??? – Shiva May 28 '14 at 13:03
  • 1
    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. – tobmuell May 29 '14 at 14:36

1 Answers1

1

This is correct answer to set styleSheet of QProgressBar:

 QString style=NULL;
setValue(40);
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");}");
setStyleSheet(style);