以QWT提供的例程sinusplot为例
QLinearGradient gradient( rect().topLeft(), rect().bottomLeft() ); //设置渐变的起始位置和终止位置
gradient.setColorAt( 0.0, Qt::white ); //在0位置设置成白色
gradient.setColorAt( 0.7, buttonColor ); //在7/10处设置成按钮颜色
gradient.setColorAt( 1.0, buttonColor ); //在1位置处设置成按钮色
//起始位置到终止位置构成一个区间,上述区间的写法是该位置在整个区间的比重位置。(如开始位置为0,终止位置为1,中间位置为0.5)
pal.setBrush( QPalette::Window, gradient );
setPalette( pal );