QT开发中文网

QString styl = "QPushButton{background-color: rgb(225, 225, 225);border:2px groove gray;border-radius:5px;padding:2px 4px;border-style: outset;}" "QPushButton:hover{background-color:rgb(229, 241, 251); color: black;}" ...

在上述的样式表中,没有直接设置按钮的边距。如果您想要为按钮设置边距,可以在样式表中添加 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助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://qt.0voice.com/?id=11758

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?