The Wayback Machine - https://web.archive.org/web/20240908235005/https://www.geeksforgeeks.org/pyqt5-add-border-to-off-state-combobox-when-pressed/
Open In App

PyQt5 – Add border to OFF state ComboBox when pressed

Last Updated : 23 Jan, 2023
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

In this article we will see how we can add border to the combo box when it is in off state and it get pressed. OFF state is basically when the combo box list view is not open. This customized border appear only when combo box will be in off state and it is pressed. In order to do this we have to change the style sheet associated with the combo box, below is the style sheet code

QComboBox::!off:pressed
{
border : 3px solid blue;
}

Below is the implementation 

Python3




# 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, 600, 400)
 
        # calling method
        self.UiComponents()
 
        # showing all the widgets
        self.show()
 
    # method for widgets
    def UiComponents(self):
 
        # creating a combo box widget
        self.combo_box = QComboBox(self)
 
        # setting geometry of combo box
        self.combo_box.setGeometry(200, 150, 150, 30)
 
        # geek list
        geek_list = ["Sayian", "Super Sayian", "Super Sayian 2", "Super Sayian B"]
 
        # adding list of items to combo box
        self.combo_box.addItems(geek_list)
 
        # editing style sheet code of combo box
        # adding border to the combo box when it is in off state
        # and when it get pressed
        self.combo_box.setStyleSheet("QComboBox::! on:pressed"
                                     "{"
                                     "border : 3px solid blue;"
                                     "}")
 
 
# create pyqt5 app
App = QApplication(sys.argv)
 
# create the instance of our Window
window = Window()
 
# start the app
sys.exit(App.exec())


Output :



Similar Reads

PyQt5 - Add border to editable off state ComboBox when pressed
In this article we will see how we can add border to the editable combo box when it is in off state and get pressed. OFF state is basically when the combo box list view is not open. This customized border appear only when combo box will be in off state and is editable and it is pressed Editable combo box can be created with the help of setEditable
2 min read
PyQt5 ComboBox - Different border color when in OFF state and get pressed
In this article we will see how we can set different border color to the combo box when it is in OFF get pressed, when we set border to the combo box it is of same color for all the sides although we can change color of each sides respectively. Colorful border will only appear combo box is in off state and combo box get pressed In order to do so we
2 min read
PyQt5 – Background color to ComboBox OFF state if pressed
In this article we will see how we can set the background color to the combo box when it is in off state and it get pressed. By default combo box is of grey color although we can change its color. This background color only appear when combo box widget is in off state and it get pressed. OFF state of combo box is basically when the drop down menu i
2 min read
PyQt5 – Setting background color to non editable OFF state ComboBox when pressed
In this article we will see how we can set the background color to the non editable combo box which is currently in the OFF state and when it get pressed. OFF state of the combo box is when the list menu is not opened. This background color will only appear if the combo box is non editable and in OFF state and when combo box get pressed. In order t
2 min read
PyQt5 – Set background color to editable OFF state ComboBox when pressed
In this article we will see how we can set the background color to the editable combo box which is currently in the OFF state and when it get pressed. OFF state of the combo box is when the list menu is not opened. This background color will only appear if the combo box is editable and in OFF state and when combo box get pressed. Combo box is made
2 min read
PyQt5 – Background image to non-editable OFF state ComboBox when pressed
In this article we will see how we can set background image to the combo box when it is non-editable off state and it get pressed. By default combo box has no image although we can set image to it. Background image will appear only when combo box is in non-editable state, in off state and get pressed. OFF state is when list view is not open. In ord
2 min read
PyQt5 – Background image to editable OFF state ComboBox when pressed
In this article we will see how we can set background image to the combo box when it is editable off state and it get pressed. By default combo box has no image although we can set image to it. Background image will appear only when combo box is in editable state, in off state and get pressed. OFF state is when list view is not open. In order to do
2 min read
PyQt5 – Background image to OFF state ComboBox when pressed
In this article we will see how we can set background image to the combo box when it is off state and get pressed. By default combo box has no image although we can set image to it. Background image will appear only when combo box is in off state and combo box is pressed. OFF state is when the list view is not open. In order to do this we have to c
2 min read
PyQt5 - Set skin to combobox when in OFF state and pressed
In this article we will see how we can set skin to the combo box when it is in off state and get pressed. OFF state is basically when list view part is not opened. Skin is background image which adjust itself according to the size of combo box. Skin will only appear to the combo box when combo box list view(item view) part is not opened and pressed
2 min read
PyQt5 – Set skin to editable off state combobox when pressed
In this article we will see how we can set skin to the editable combo box when it is in off state and when it get pressed. Skin is basically the background image but skin adjust its size according to the size of combo box. OFF state is when list view(item view) is not open, setEditable method is used to make combo box editable. Skin will only appea
2 min read
PyQt5 – Set skin to non-editable off state combobox when pressed
In this article we will see how we can set skin to the non-editable combo box when it is in off state and when it get pressed. Skin is basically the background image but skin adjust its size according to the size of combo box. OFF state is when list view(item view) is not open, setEditable method is used to make combo box editable. Skin will only a
2 min read
PyQt5 - Add border to editable off state ComboBox when mouse hover
In this article we will see how we can add border to the editable combo box when it is in off state and mouse hover over it. OFF state is basically when the combo box list view is not open. This customized border appear only when combo box will be in off state and is editable and mouse hover over it. Editable combo box can be created with the help
2 min read
PyQt5 - Add border to ComboBox when it get pressed
In this article we will see how we can add border to the combo box when it get pressed. By default combo box have border although we can change the border, combo box with customized border will only appear when it get pressed. In order to do this we have to change the style sheet associated with the combo box, below is the style sheet code QComboBo
2 min read
PyQt5 – Add border to editable ComboBox when pressed
In this article we will see how we can add border to the combo box when it is editable and when it get pressed. By default combo box have border although we can change the border, combo box with customized border will only appear when it is editable and it is pressed. Editable combo box can be made with the help of setEditable method In order to do
2 min read
PyQt5 – Add border to non-editable ComboBox when pressed
In this article we will see how we can add border to the combo box when it is non-editable and when it get pressed. By default combo box have border although we can change the border, combo box with customized border will only appear when it is non-editable and it is pressed. In order to do this we have to change the style sheet associated with the
2 min read
PyQt5 - Add border to drop arrow of ComboBox when pressed
In this article we will see how we can border to the drop arrow of the combo box when it get pressed. Drop arrow is basically a push button which when get pressed opens the list view. This customized border will only appear to the drop arrow when it get pressed. In order to do so we have to change the style sheet associated with the combo box, belo
2 min read
PyQt5 Combo Box - Different border size when in OFF state when get pressed
In this article we will see how we can set different border width to the combo box when Combobox is in the off state and it gets pressed, when we set border to the combo box it is of same width for all the sides although we can change width of each sides respectively, border with different width will only appear when combo box is off state and comb
2 min read
PyQt5 QComboBox - Change border style when it is in off state and when it get pressed
In this article we will see how we can change the border style of the combo box when it is in off state and get pressed, border style can be dotted, dashed etc. When we set border to the combo box it is continuous although we can change it. Styled border will be only visible when combo box is in off state and it gets pressed else normal border will
2 min read
PyQt5 - Adding border to OFF state ComboBox
In this article we will see how we can add border to the combo box when it is in off state. OFF state is basically when the combo box list view is not open. This customized border appear only when combo box will be in off state. In order to do this we have to change the style sheet associated with the combo box, below is the style sheet code QCombo
2 min read
PyQt5 - Adding border to OFF state ComboBox when mouse hover
In this article we will see how we can add border to the combo box when it is in off state and mouse hover it. OFF state is basically when the combo box list view is not open. This customized border appear only when combo box will be in off state and mouse is hovering over it. In order to do this we have to change the style sheet associated with th
2 min read
PyQt5 - Adding border to editable off state ComboBox
In this article we will see how we can add border to the editable combo box when it is in off state. OFF state is basically when the combo box list view is not open. This customized border appear only when combo box will be in off state and is editable. Editable combo box can be created with the help of setEditable method. In order to do this we ha
2 min read
PyQt5 - Adding border to non-editable off state ComboBox
In this article we will see how we can add border to the non-editable combo box when it is in off state. OFF state is basically when the combo box list view is not open. This customized border appear only when combo box will be in off state and is non-editable. In order to do this we have to change the style sheet associated with the combo box, bel
2 min read
PyQt5 - Adding border to non-editable off state ComboBox when mouse hover
In this article we will see how we can add border to the non-editable combo box when it is in off state and mouse hover over it. OFF state is basically when the combo box list view is not open. This customized border appear only when combo box will be in off state and is non-editable and mouse hover over it. In order to do this we have to change th
2 min read
PyQt5 ComboBox - Different border color when it is in OFF state
In this article we will see how we can set different border color to the combo box when it is in OFF state, when we set border to the combo box it is of same color for all the sides although we can change color of each sides respectively. Colorful border will only appear combo box is in off state i.e list view is not opened. In order to do so we ha
2 min read
PyQt5 ComboBox - Different border size when it is in OFF state
In this article we will see how we can set different border width to the combo box when combobox is in the off state, when we set border to the combo box it is of same width for all the sides although we can change width of each sides respectively, border with different width will only appear when combo box is off state else it will show normal bor
2 min read
PyQt5 ComboBox - Different border size when it is in OFF state when mouse hover it
In this article we will see how we can set different border width to the combo box when combo box is in the off state and mouse hover over it, when we set border to the combo box it is of same width for all the sides although we can change width of each sides respectively, border with different width will only appear when combo box is off state and
2 min read
PyQt5 ComboBox – Different border size when editable and in off state
In this article we will see how we can set different border width to the combobox when it is editable and is in off state, when we set border to the combo box it is of same color for all the sides although we can change color of each side respectively. Different border-width will only appear combo box is editable and its list view is not opened. No
2 min read
PyQt5 ComboBox - Different border color when non-editable and off state
In this article, we will see how we can set different border color to the combo box when it is non-editable and off state, when we set border to the combo box it is of same color for all the sides although we can change color of each sides respectively. Colorful border will only appear combo box is non-editable and item view is not opened. Note : C
2 min read
PyQt5 ComboBox - Different border color when editable and off state
In this article we will see how we can set different border color to the combo box when it is editable and off state, when we set border to the combo box it is of same color for all the sides although we can change color of each sides respectively. Colorful border will only appear combo box is editable and item view is not opened. Note : Combo box
2 min read
PyQt5 – Background image to pressed indicator when pressed from checked state | Check Box
In this article we will see how to add background image to the pressed indicator which was initially in the checked state. In order to do this we have to change the style sheet code associated with the check box object and have to add background image to the indicator of checked state when it get pressed. Below is the style sheet code. QCheckBox::i
2 min read