【发布时间】:2021-09-03 22:44:25
【问题描述】:
我在源文件“.cpp”中创建了一个qpushbutton:
QPushButton * btn = new QPushButton("Click me");
现在我想给它添加样式。比如改变背景、添加边框半径、改变光标等等。
【问题讨论】:
标签: c++ qt styles qwidget qpushbutton
我在源文件“.cpp”中创建了一个qpushbutton:
QPushButton * btn = new QPushButton("Click me");
现在我想给它添加样式。比如改变背景、添加边框半径、改变光标等等。
【问题讨论】:
标签: c++ qt styles qwidget qpushbutton
这对我来说很好用:
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;}"
));
【讨论】: