Resolve the problem that the QToolButton in pyqt5 cannot be used

Time:2019-8-11

When you use the QToolButton in pyqt, if you want to achieve different functions by pressing and lifting, you must add this sentence:


self.btn_1.setCheckable(True)

The basic code for setting up a toolbutton is:


 self.btn_1 = QToolButton(self)
 self.btn_1.setText('start')
 self.btn_1.setCheckable(True)
 self.btn_1.clicked.connect(self.btn_1_function)
 
 
def btn_1_function(self):
  if self.btn_1.isChecked():
    pass
  else:
    pass

The above article to solve the problem that the QoolButton in pyqt5 can not be used is the whole content shared by the editor. I hope to give you a reference, and I hope you will support developpaer more.

Recommended Today

Manjaro uses SS method (requires nodejs environment)

Just installed manjaro, need to installshadowsocks-qt5+Proxy SwitchyOmega, but the latest Chrome has long blocked the installation of non Google store CRX channels. Here is my solution, which is troublesome but usable. If you are familiar with NPM commands in nodejs, you won’t find it troublesome, because nodejs is used for compilation. Preparation environment: A VPS […]