简体   繁体   English

为QProgressBar上的Image设置颜色

[英]Color the Image setting on QProgressBar

Actually I set an image on a QProgressBar and want to change the color of image according to selected part of QProgressBar . 实际上,我在QProgressBar上设置了图像,并想根据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. 我尝试用QProgressBar颜色覆盖图像,但该图像会填充图像,但是由于我的图像不是矩形,因此会为整个QProgressBar着色,而不仅仅是图像。

Is it possible to change color of image only using qt (with C++) 是否可以仅使用qt更改图像的颜色(使用C ++)

You are looking for Qt Style Sheet Documentation . 您正在寻找Qt样式表文档 You can customize your own QProgressBar, and add your own setProgress() function which should update the value property . 您可以自定义自己的QProgressBar,并添加自己的setProgress()函数,该函数应更新value属性 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 有关更多详细信息,请参见QSS示例: 样式表示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM