Chapter 10. Adding the new method implementations

Support for the alpha slider

First, we add a public slot to CentralView called setAlpha(int v). The implementation of that method only calls m_timer.start(200,true); in order to start an update of the pixmap .

Then, we change the updatePixmap method to use the alpha slider value. We change it from

KImageEffect::blend(m_color, image, 0.5 );
KImageEffect::blend(m_color, image, m_alpha->value()/100.0 );
So that the resulting value is in the interval [0,1] (because we previously set the maximum value of m_alpha to 100 in Designer).

Support for the color button

We're going to add a new method to CentralView called setColor.

void CentralView::setColor(const QColor &color)
Note that this is enough to set the color as it will set the three components, emiting the three respective signals and calling setRed, setGreen and setBlue and it will not flicker because the timer will be restarted each time a value is changed (due to the signals that the sliders emit when the value is modified) and so, updatePixmap will be called only once.

With this change, we now have a fully working application, that we'll call s7.