VOOZH about

URL: https://www.geeksforgeeks.org/python/pyqt5-qcommandlinkbutton-background-color-for-combined-checked-and-pressed-states/

⇱ PyQt5 QCommandLinkButton – Background Color for Combined Checked and Pressed states - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PyQt5 QCommandLinkButton – Background Color for Combined Checked and Pressed states

Last Updated : 22 Feb, 2023

In this article we will see how we can set background color to the checkable QCommandLinkButton according to the checked and hover states combined. Command link button is a special type of button it has qualities of both push-button and the radio button. By default, there is no extra background color to the command link button although we can set custom background color to it any time. We can make the command link button checkable with the help of setCheckable method, there are basically two checked states one is checked i.e when it is in pressed state and other is the unchecked state i.e when it is in the released state. In order to do this we will set style sheet code to it for that we use setStyleSheet method with the command link button object, below is the stylesheet code

QCommandLinkButton::checked
{
background-color : lightgreen;
}
QCommandLinkButton::checked::pressed
{
background-color : yellow;
}
QCommandLinkButton::!checked
{
background-color : red;
}
QCommandLinkButton::!checked::pressed
{
background-color : pink;
}

Below is the implementation 

Output :

Comment