PyQt5 – QCommandLinkButton Class

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

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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):
        super().__init__()
  
        # setting title
        self.setWindowTitle("Python ")
  
        # setting geometry
        self.setGeometry(100, 100, 500, 400)
  
        # calling method
        self.UiComponents()
  
        # showing all the widgets
        self.show()
  
  
    # 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
            label.setText(str(self.n))
  
  
# create pyqt5 app
App = QApplication(sys.argv)
  
# create the instance of our Window
window = Window()
  
# start the app
sys.exit(App.exec())

chevron_right


Output :




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.