【问题标题】:Adding styles to QPushButton向 QPushButton 添加样式
【发布时间】:2021-09-03 22:44:25
【问题描述】:

我在源文件“.cpp”中创建了一个qpushbutton:

QPushButton * btn = new QPushButton("Click me");

现在我想给它添加样式。比如改变背景、添加边框半径、改变光标等等。

【问题讨论】:

标签: c++ qt styles qwidget qpushbutton


【解决方案1】:

这对我来说很好用:

btn->setObjectName("mybtn");
btn->setStyleSheet(QString(""
                         "#mybtn{background-color: #182848; border-radius: 5px; border: 1px solid transparent; color: white;}"
                         "#mybtn:hover{background-color: white; border-color: #182848; color: #182848;}"
                         ));

【讨论】:

    猜你喜欢
    • 2012-07-07
    • 1970-01-01
    • 1970-01-01
    • 2019-04-04
    • 2015-08-05
    • 2012-11-19
    • 2019-02-04
    • 2013-09-15
    • 1970-01-01
    相关资源
    最近更新 更多