PDA

View Full Version : Qt Style Sheets: Create pane of buttons with no space in between them



glimberg
6th April 2010, 20:10
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:



QPushButton {
color: black;
background-color: white;
border-width: 0px;
border-style: solid;
margin: 0;
padding: 10px;
font-size: 14px;
min-width: 150px;
min-height: 15px;
}

QPushButton:pressed {
background-color: blue;
color: white;
}

QPushButton:checked {
background-color: blue;
color: white;
}


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?

Lykurg
6th April 2010, 21:18
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.

glimberg
6th April 2010, 21:42
That did the trick. Thanks!