Results 1 to 3 of 3

Thread: Qt Style Sheets: Create pane of buttons with no space in between them

  1. #1
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt Style Sheets: Create pane of buttons with no space in between them

    I'm attempting to create a vertical layout of 5 buttons used for navigation in a program. They're white buttons with black text when unselected, and blue buttons with white text when selected. Ideally, I'd like to have them with no space in between them. Here's the style sheet I'm currently using for the buttons:

    Qt Code:
    1. color: black;
    2. background-color: white;
    3. border-width: 0px;
    4. border-style: solid;
    5. margin: 0;
    6. padding: 10px;
    7. font-size: 14px;
    8. min-width: 150px;
    9. min-height: 15px;
    10. }
    11.  
    12. QPushButton:pressed {
    13. background-color: blue;
    14. color: white;
    15. }
    16.  
    17. QPushButton:checked {
    18. background-color: blue;
    19. color: white;
    20. }
    To copy to clipboard, switch view to plain text mode 

    This works fine on Mac OS X. There's no visible space between the buttons, however on windows, there's always a few pixels worth of background viewable between each button. I've tried setting negative margins, but that doesn't do anything but make each individual button a bit smaller. Anyone know of a way to achieve buttons that are "Stacked" like this?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Qt Style Sheets: Create pane of buttons with no space in between them

    I not 100% sure, but I guess it is related to the layout which holds your buttons. The default values for spacing and margin differ on the different platforms. So you can try to set the values manually and see if it will work on windows.

  3. The following user says thank you to Lykurg for this useful post:

    glimberg (6th April 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt Style Sheets: Create pane of buttons with no space in between them

    That did the trick. Thanks!

Similar Threads

  1. Custom buttons using style sheets
    By GrahamLabdon in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2011, 21:53
  2. Do Qt Style Sheets support List-style-image?
    By daiheitan in forum Qt Programming
    Replies: 6
    Last Post: 12th March 2010, 01:41
  3. Replies: 1
    Last Post: 26th July 2009, 15:08
  4. style sheets
    By alisami in forum Qt Programming
    Replies: 8
    Last Post: 7th May 2009, 09:41
  5. Qt style sheets
    By locus in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2007, 17:03

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.