【发布时间】:2015-04-29 10:58:19
【问题描述】:
当我在 QPushButton 上应用样式表时,它的尺寸会发生变化。 这是我的样式表声明。
QPushButton {
background-color: rgb(175, 187, 199);
color: black;
border-width: 1px;
border-top: 1px solid white;
border-left: 1px solid white;
border-right: 1px solid grey;
border-bottom: 1px solid grey;
border-style: solid;
border-radius: 5;
padding: 3px;
padding-left: 5px;
padding-right: 5px;
font: 16px;
font-weight: bold;
}
Image - Before applying style sheet
Image - After applying style sheet
如何保持原来的按钮大小?
【问题讨论】:
-
您可以在样式表中添加
min-width。 -
最小宽度影响所有按钮:(
-
这个样式表应该影响所有按钮,所以......?也许您应该在样式表中添加一些限定条件?
-
@MarekR 我创建的对话框中的 QPushButtons 是可能的,但是我不知道如何为 QMessageBox 中的按钮执行此操作。有什么想法吗?
-
是的,有可能,看我的回答。
标签: qt qt4 stylesheet qtstylesheets qpushbutton