How to set the QToolButton's icons using style sheet?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 10:23:01

Later that day I managed to somehow solve the problem, but forgot to post the solution :

QString FormStyleSheetString( const QString & name )
{
  const QString thisItemStyle(
  "QToolButton {\n"
                "   border: none;\n"
                "   background: url(" + name + "_normal.png) top center no-repeat;\n"
                "   padding-top: 200px;\n"
                "   width: 200px;\n"
                "   font: bold 14px;\n"
                "   color: red;\n"
                "}\n"
                "QToolButton:hover {\n"
                "   background: url("+name+"_hover.png) top center no-repeat;\n"
                "   color: blue;\n"
                "}\n"
                "QToolButton:pressed {\n"
                "   background: url("+name+"_pressed.png) top center no-repeat;\n"
                "   color: gray;\n}" );

  return thisItemStyle;
}

It wasn't enough just to set the background. It also needed the size fixed.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!