Results 1 to 1 of 1

Thread: button with backgr and icon using stylesheets

  1. #1
    Join Date
    May 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default button with backgr and icon using stylesheets

    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.
    Qt Code:
    1. color: black;
    2. border-image: url(../qss/NormalButton.png) 2 10 2 10 stretch;
    3. border-top: 2px transparent;
    4. border-bottom: 2px transparent;
    5. border-right: 10px transparent;
    6. border-left: 10px transparent;
    7. font-family:"Tahoma";
    8. font: 10px;
    9. min-height:28px;
    10. max-height:28px;
    11. }
    To copy to clipboard, switch view to plain text mode 
    for this button I need to add an icon so I added
    Qt Code:
    1. #RotateLeft{
    2. image:url(../qss/RotateLeft.png), url(RotateLeft_roll.png) selected, url(RotateLeft_disabled.png) disabled;
    3. image-position: left;
    4. text-align:center;
    5. padding-left: -6px;
    6. padding-right: -6px;
    7. }
    To copy to clipboard, switch view to plain text mode 
    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
    Last edited by jpn; 13th May 2008 at 08:49. Reason: missing [code] tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.