【问题标题】:How to Set Image on QPushButton on Left hand side in QT?如何在 QT 左侧的 QPushButton 上设置图像?
【发布时间】:2011-09-14 10:21:50
【问题描述】:

如何在 QT 左侧的 QPushButton 上设置图像?

我正在使用以下代码使用样式表在按钮上设置图像。 但这给了我很多次相同的图像,我只希望在我的按钮左侧也有一个显示。

 b1->setStyleSheet(

               "background-image: url(:/user.gif);"
               "border-style: outset;"
               "border-width: 2px;"
               "border-radius: 10px;"
               "border-color: black;"
               "font: bold 16px;"
               "color: black;"
               "min-width: 10em;"
               "min-height: 0.75em;"
               "margin: 0 1px 0 1px;"
               "color:rgb(0,0,0);"
               "padding: 6px;"
               ); 

我使用以下方法解决了我的问题:

"background-repeat:no-repeat;"                  
               "background-position:left top;"

【问题讨论】:

  • 不要忘记点击 OrcunC 答案旁边的复选标记来接受他的答案。

标签: qt


【解决方案1】:

您需要在样式表中添加background-repeat no-repeat;

【讨论】:

    猜你喜欢
    • 2011-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多