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

Implementation of PHP Facades

Example <?php class RealRoute{ public function get(){ Echo’Get me’; } } class Facade{ public static $resolvedInstance; public static $app; public static function __callStatic($method,$args){ $instance = static::getFacadeRoot(); if(!$instance){ throw new RuntimeException(‘A facade root has not been set.’); } return $instance->$method(…$args); } // Get the Facade root object public static function getFacadeRoot() { return static::resolveFacadeInstance(static::getFacadeAccessor()); } protected […]