0

Actually I set an image on a QProgressBar and want to change the color of image according to selected part of QProgressBar.

I tried covering my image with QProgressBar color but that fills the image, but as my image is not a rectangle it color the whole QProgressBar and not just the image.

Is it possible to change color of image only using qt (with C++)

frogatto
  • 28,539
  • 11
  • 83
  • 129
prince
  • 1
  • 1

1 Answers1

0

You are looking for Qt Style Sheet Documentation. You can customize your own QProgressBar, and add your own setProgress() function which should update the value property. You could modify the image background, the border, margins... depending of the value of the current value.

See QSS examples for more detail: Example Style Sheet

mohabouje
  • 3,867
  • 2
  • 14
  • 28
  • Actually i m not looking for StyleSheet.I m looking for a method to set color on image according to selection on QProgressbar.It must be noted that image is set on the QProgressBar. – prince Sep 20 '16 at 12:20
  • 1
    This is wrong, please fix it. There is no function named `setProgress` in [`QProgressBar`](https://doc.qt.io/qt-5/qprogressbar.html#details). And if you meant [`setValue`](https://doc.qt.io/qt-5/qprogressbar.html#value-prop) it is not a virtual function that you need to override, and even if you really had to, it does **not** have to do with styling at all. Please try reading the [link](https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qprogressbar) you provided. – Mike Sep 20 '16 at 15:32