PDA

View Full Version : menu repaint



georgie
15th May 2006, 09:21
I want to get a background which fades from white to blue...easy...

QPainter painter;
painter.setPen(Qt::NoPen);
painter.setBackgroundMode(Qt::TransparentMode);


QLinearGradient grad(0, 300, 3000, 3000);
grad.setColorAt(0, Qt::white);
grad.setColorAt(1, Qt::blue);
palette.setBrush(QPalette::Background, grad);
at least I thought it was easy, 'til I realised that my File/Edit menu titles were going black with black text when I rolled over them and when they were open the whole menu became black on black....

the weird thing is, that if I relace that last line with


palette.setBrush(QPalette::Background, Qt::blue);

everything is how you would expect it to be...
I also changed QPalette::Background to QPalette::Window and the exact same thing happened :(

wysota
15th May 2006, 16:55
Some objects don't handle gradients and when you try to use one as a brush, you get a black solid brush instead. This might be the case here. Do you experience the same behaviour with other QStyles too? One of them might handle it...

georgie
16th May 2006, 05:40
thanks
yeah, you are right....the way I fixed it was to use a pixmap of a gradient i made in gimp instead :P is this cheating?
works a charm now....thx