在上述的样式表中,没有直接设置按钮的边距。如果您想要为按钮设置边距,可以在样式表中添加 padding
属性来调整按钮内容与边框之间的距离。
例如,如果您想要在样式表中设置按钮的左右边距为10像素,可以将样式表修改如下:
QString styl = "QPushButton{"
"background-color: rgb(225, 225, 225);"
"border: 2px groove gray;"
"border-radius: 5px;"
"padding: 2px 10px;" // 设置左右边距为10像素
"border-style: outset;"
"}"
"QPushButton:hover{"
"background-color: rgb(229, 241, 251);"
"color: black;"
"}"
"QPushButton:pressed{"
"background-color: rgb(204, 228, 247);"
"border-style: inset;"
"}";
通过修改 padding
的值,您可以调整按钮的内部内容与边框之间的距离。请根据需要进行调整,并注意保持样式表语法正确性。
内容由零声教学AI助手提供,问题来源于学员提问