PyQt5 QCommandLinkButton - Setting Auto Repeat Property
Last Updated : 30 Jun, 2020
In this article we will see how we can set the auto repeat property of the QCommandLinkButton. If auto repeat property is enabled, then the pressed, released, and clicked signals are emitted at regular intervals when the command link button is down. Auto repeat property is off by default. The initial delay and the repetition interval are defined in milliseconds by autoRepeatDelay and autoRepeatInterval method.
In order to do this we use setAutoRepeat method with the command link button object
Syntax : button.setAutoRepeat(True)
Argument : It takes bool as argument
Return : It return None
Below is the implementation
Python3 1==
# importing librariesfromPyQt5.QtWidgetsimport*fromPyQt5importQtCore,QtGuifromPyQt5.QtGuiimport*fromPyQt5.QtCoreimport*importsysclassWindow(QMainWindow):def__init__(self):super().__init__()# setting titleself.setWindowTitle("Python ")# setting geometryself.setGeometry(100,100,500,400)# calling methodself.UiComponents()# showing all the widgetsself.show()# method for componentsdefUiComponents(self):# creating a command link buttoncl_button=QCommandLinkButton("Press",self)# setting geometrycl_button.setGeometry(250,100,200,50)# setting auto repeatcl_button.setAutoRepeat(True)# creating labellabel=QLabel("GeeksforGeeks",self)# setting label geometrylabel.setGeometry(100,100,200,40)# counterself.counter=0# adding action to the buttoncl_button.clicked.connect(lambda:update_label())# method for updating label textdefupdate_label():# setting label textlabel.setText(str(self.counter))# incrementing the counterself.counter+=1# create pyqt5 appApp=QApplication(sys.argv)# create the instance of our Windowwindow=Window()# start the appsys.exit(App.exec())