Skip to content
Related Articles

Related Articles

PyQt5 – QCommandLinkButton Class
  • Last Updated : 26 Jun, 2020

QCommandLinkButton is a control widget that was introduced by Windows Vista. Its intended use is similar to that of a radio button in that it is used to choose between a set of mutually exclusive options. The appearance of it is generally similar to that of a flat push button, but it allows for a descriptive text in addition to the normal button text. By default it will also carry an arrow icon, indicating that pressing the control will open another window or page or do something. Below is how the command link button looks like

Example :
We will create a window having a label and the command link button and when the command link button pressed the counter will increment in the label

Below is the implementation

# importing libraries
from PyQt5.QtWidgets import * 
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import * 
from PyQt5.QtCore import * 
import sys
class Window(QMainWindow):
    def __init__(self):
        # setting title
        self.setWindowTitle("Python ")
        # setting geometry
        self.setGeometry(100, 100, 500, 400)
        # calling method
        # showing all the widgets
    # method for components
    def UiComponents(self):
        # counter value
        self.n = 0
        # creating label
        label = QLabel("Counter", self)
        # setting label geometry
        label.setGeometry(100, 100, 100, 40)
        # creating a command link button
        cl_button = QCommandLinkButton("Next", self)
        # setting geometry
        cl_button.setGeometry(200, 100, 200, 40)
        # adding action to the button
        cl_button.clicked.connect(lambda: increment(self.n))
        # method for incrementing the counter
        def increment(n):
            # increment
            self.n = n + 1
            # setting text to the label
# create pyqt5 app
App = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# start the app

Output :

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :