QPushButton设置背景图片,设置背景透明度

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

 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);}");

 

posted @ 2020-04-06 11:16  码林斋  阅读(11084)  评论(0编辑  收藏  举报