Method of setting icon and css style for button with pyqt5

  • 2021-07-01 07:39:28
  • OfStack

As shown below:

Setting icon


self.pushButton.setIcon(QIcon("sure.png"))

Setting css Style


self.pushButton.setStyleSheet("QPushButton{color:black}"
                    "QPushButton:hover{color:red}"
                    "QPushButton{background-color:lightgreen}"
                    "QPushButton{border:2px}"
                    "QPushButton{border-radius:10px}"
                    "QPushButton{padding:2px 4px}")

Related articles: