cpsmusic
1st June 2011, 14:59
Hi,
I'm currently working on an audio application that requires a volume meter. I'm going to implement this as a custom widget and override the paintEvent method. I'd like the meter display (basically a coloured rectangle) to change colour depending on the current signal value, changing from green to yellow to orange to red as the meter approaches full scale.
Initially, I was going to calculate the meter's display on the fly using QLinearGradient. While I think this will work, I was thinking that because the colour value of each meter degree is always the same it would be better to create the full meter display in an offscreen buffer, and then copy whatever portion of it corresponds to the current signal value and render that.
Can I use something like QPixmap for rendering the full meter display and then copy parts of it during rendering? Any suggestions on how to implement this?
Cheers,
Chris
I'm currently working on an audio application that requires a volume meter. I'm going to implement this as a custom widget and override the paintEvent method. I'd like the meter display (basically a coloured rectangle) to change colour depending on the current signal value, changing from green to yellow to orange to red as the meter approaches full scale.
Initially, I was going to calculate the meter's display on the fly using QLinearGradient. While I think this will work, I was thinking that because the colour value of each meter degree is always the same it would be better to create the full meter display in an offscreen buffer, and then copy whatever portion of it corresponds to the current signal value and render that.
Can I use something like QPixmap for rendering the full meter display and then copy parts of it during rendering? Any suggestions on how to implement this?
Cheers,
Chris