gpt4 book ai didi

qt - 如何设置影响按钮大小的 QPushButton 样式表?

转载 作者:行者123 更新时间:2023-12-04 13:19:14 28 4
gpt4 key购买 nike

当我 QApplication::setStyleSheet() 使用以下样式表时

QPushButton {
border-radius: 2px;
padding: 0.2em 0.2em 0.3em 0.2em;
border: 1px solid rgb(100, 100, 100);
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #f4f4f4, stop:0.1 #8F8F8F, stop:1 #7B7B7B);
color: white;
}

所有按钮的大小都被截断为文本的大小。例如,OK 按钮变成方形。效果与我在 QPushButton 上尝试的任何其他样式表相同。如何设置按钮样式表而不影响其默认大小?

最佳答案

我不认为你可以在不影响小部件的默认大小的情况下弄乱边框或填充。您可以设置 min-width 尽管。

来自文档:If this property is not specified, the minimum width is derived based on the widget's contents and the style.

QPushButton {
border-radius: 2px;
padding: 0.2em 0.2em 0.3em 0.2em;
border: 1px solid rgb(100, 100, 100);
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #f4f4f4, stop:0.1 #8F8F8F, stop:1 #7B7B7B);
color: white;
min-width: 70px;
}

关于qt - 如何设置影响按钮大小的 QPushButton 样式表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19385812/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com