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?

4

1 回答 1

1

这是设置 QProgressBar 的 styleSheet 的正确答案:

 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);
于 2015-11-12T09:18:23.850 回答