PDA

View Full Version : Using QStyle for QPushButton with 3 background images.



suslik
9th July 2010, 00:50
Hello everyone,

Let me start out by saying that I read the docs and the Norwegian Wood example for using QStyle, but it is my first attempt at it, and I would like to know what the best approach to do this is.

I need to style a QPushButton, and I have 3 complex images for it, left, mid, and right. In the examples I've seen so far people have had one background images that they painted on the widget, and then either drew borders or used darkened painters over it to get what they needed.

How do people usually style widgets with varied length and multiple background images (mid is supposed to be repeating)? Do you do math and then fill in the right coordinates in the paint events?

I am faced with an application that relied on style sheets, but it grew into a mess that is now getting very unmaintainable.

Thanks for any input!

aamer4yu
9th July 2010, 05:42
Do you do math and then fill in the right coordinates in the paint events?
I guess yes... You can also have a look at Qt source code as how they do it...am not sure which class though