Qt QSS: 等比例铺满 SpinBox 箭头
要将箭头等比例铺满按钮,可以使用 QSS 中的'background'属性来实现。
首先,设置 spinbox 的样式为自定义样式,例如:
QSpinBox#mySpinBox {
border: none;
padding: 0px;
}
然后,设置 spinbox 的箭头样式,例如:
QSpinBox#mySpinBox::up-button {
subcontrol-origin: border;
subcontrol-position: top right;
width: 16px;
height: 16px;
image: url(up_arrow.png);
}
QSpinBox#mySpinBox::down-button {
subcontrol-origin: border;
subcontrol-position: bottom right;
width: 16px;
height: 16px;
image: url(down_arrow.png);
}
其中,#mySpinBox 是自定义的 spinbox 的 id。
这样,箭头的宽度和高度都被设置为 16px,并且被放置在右上角和右下角的位置。
你可以根据需要调整箭头的样式和尺寸,同时替换上述代码中的图片路径为你自己的箭头图片路径。
原文地址: https://www.cveoy.top/t/topic/qpyK 著作权归作者所有。请勿转载和采集!