设置按钮的背景图片,背景透明度

 1   QPushButton *push_button = new QPushButton;
 2   push_button->setMaximumSize(32, 32);
 3   push_button->setMinimumSize(32, 32);
 4   QIcon btn_icon;
 5   btn_icon.addFile("images/add.png");
 6   push_button->setIcon(btn_icon);
 7   push_button->setIconSize(QSize(32, 32));
 8   // 1、push_button->setFlat(true);  //按钮背景为透明,但是有边框
 9   // 2、通过样式表改变按钮的背景
10   push_button->setStyleSheet(
11       "QPushButton{background:rgba(0,0,0,0);border:1px solid rgba(0,0,0,0);}");

 

版权声明:本文为malinzhai原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/malinzhai/p/12641185.html