PDA

View Full Version : button with backgr and icon using stylesheets



s_p_t10
7th May 2008, 20:19
Hi,
I am new at working with QStylesheets and am not able to get a button with background Image and an icon working correctly. Can someone please help me with the spacing and padding issue here.

In general all my buttons use the following stylesheet which works fine.

QPushButton{
color: black;
border-image: url(../qss/NormalButton.png) 2 10 2 10 stretch;
border-top: 2px transparent;
border-bottom: 2px transparent;
border-right: 10px transparent;
border-left: 10px transparent;
font-family:"Tahoma";
font: 10px;
min-height:28px;
max-height:28px;
}
for this button I need to add an icon so I added

#RotateLeft{
image:url(../qss/RotateLeft.png), url(RotateLeft_roll.png) selected, url(RotateLeft_disabled.png) disabled;
image-position: left;
text-align:center;
padding-left: -6px;
padding-right: -6px;
}
and what I see is the icon and text overlapping.
If I delete the padding -6px lines, the icon and text both move towards the inside and the button size increases a little. But how do I calculate the size of the button to be the size of the button + size of icon using StyleSheets. I don't want to arbitrarily increase the button width because on localization, the text on the button would change and could be much longer.

Please help. Thanks