1

I would like to make a gradient for a QStyleSheet that does the following: 1) Transparent top 40%. 2) Opaque middle 20%, going from black to white. 3) Transparent bottom 40%.

A good example would be thinking of a 3-color flag, but I want the top and bottom transparent, and where the top and bottom are transparent, and the center is going from solid-black to white.

Basically I would like to somehow merge the following two linear gradients together, but I lack the knowledge to do so.

background-color: QLinearGradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0.39 rgba(0, 0, 0, 0), stop:0.4 rgba(0,0,0,255), stop:0.6 rgba(0,0,0,255), stop:0.61 rgba(0, 0, 0, 0) );

and...

background-color: QLinearGradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255) );

1 Answer 1

1

I think you might be able to use a gradient to achieve this, but it would be difficult.

However, the easier way would be to override the style's drawing for the scroll bars, and paint your black/white gradient while clipping it to ensure the desired areas are still transparent. Unfortunately, that solution doesn't rely solely on style sheets.

A third option, depending on your platform and capabilities, might be to create an image and set the background to that image, stretched (where necessary).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.