PyQt5 QSpinBox - Add border to the down button

PyQt5 QSpinBox - Add border to the down button

To add a border to the down button of a QSpinBox in PyQt5, you can use Qt Style Sheets (similar to CSS for web).

The down button of the QSpinBox is a sub-control named QSpinBox::down-button. You can apply styles to this sub-control using a style sheet.

Here's how you can add a border to the down button of a QSpinBox:

import sys from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QSpinBox class AppDemo(QWidget): def __init__(self): super().__init__() layout = QVBoxLayout(self) spin_box = QSpinBox(self) # Applying stylesheet to QSpinBox's down button spin_box.setStyleSheet(""" QSpinBox::down-button { border: 2px solid red; } """) layout.addWidget(spin_box) app = QApplication(sys.argv) window = AppDemo() window.show() sys.exit(app.exec_()) 

In this example, the down button of the QSpinBox will have a 2-pixel wide red border. You can adjust the border properties (color, width, style, etc.) in the style sheet as desired.


More Tags

api woocommerce mysql-python oc4j fibonacci sockets django-userena android-toolbar seconds android-gps

More Programming Guides

Other Guides

More Programming Examples