PDA

View Full Version : QToolButton customization / skinning



Treggie
17th February 2010, 22:24
Hi,

I use some QToolButtons (text under icon) in my program. Now I want to do two things:

1. specify a different icon over stylesheet
2. draw a colored rounded, filled rectangle only as text background (not the image)

Has somebody an idea, how to achieve this or has a link to a code snippet?

Thanks in advance.

Lykurg
17th February 2010, 23:38
1. specify a different icon over stylesheet
use qproperty-icon.

Treggie
18th February 2010, 09:17
Hey man, thanks for the info! Learned a "trick" more again :)

Now I'm only searching for a way to paint only behind the text. I thought, that I could use a gradient (can I draw rounded reactangles this way?), which leaves the image area free and starts somewhere in the middle of the button. But all attempts until now don't work :(

Lykurg
18th February 2010, 10:12
I'm only searching for a way to paint only behind the text. I thought, that I could use a gradient (can I draw rounded reactangles this way?), which leaves the image area free and starts somewhere in the middle of the button. But all attempts until now don't work :(
I don't know a way to do that with style sheets. I would say you have to subclass and do some painting by yourown.

aamer4yu
18th February 2010, 10:21
Now I'm only searching for a way to paint only behind the text.
Do you mean the background? Read about background in Qt style sheets

Treggie
18th February 2010, 11:16
Correct ... I mean the background. Have already read the stylesheet docu, but haven't found a way to draw only half the background with a Gradient and keep the other half part transparent or as it is.

BalaQT
18th February 2010, 11:18
hi
for setting a image using stylesheet

t->setStyleSheet("background-image: url(computer.gif)");


for setting a transparent in a stylesheet

background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6666FF, stop: 0.7 #99CCFF , stop: 1 #CCCCFF);

work it around, u may find a solution. (im not sure ,it helps or not)
hope it helps

Bala

Lykurg
18th February 2010, 11:25
Correct ... I mean the background. than write it next time....
Have already read the stylesheet docu, but haven't found a way to draw only half the background with a Gradient and keep the other half part transparent or as it is.
Then use a gradient which is from 0.0 to 0.5 transparent and for 0.500000000000000000000000000000000000000000000000 000000000000000000000001 to 1.0 make your colours. How to use gradient has BalaQt written and all that are wounderfull explained in the docus.

Treggie
20th February 2010, 20:20
Hi Lykurg ... why so aggressive? You helped me with the first part of the question (the hint to the qproperty was helpful indeed). For the second part (as noted ... and written) in my initial question I will try the gradient (which I already know).