PyQt5 QSpinBox - Adding border to the up button

PyQt5 QSpinBox - Adding border to the up button

To add a border to the up button of a QSpinBox in PyQt5, you will need to use Qt's stylesheet feature.

Here's a simple example to demonstrate how to add a border to the up 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) # Apply the stylesheet to add a border to the up button of the QSpinBox spin_box.setStyleSheet(""" QSpinBox::up-button { border: 2px solid red; } """) layout.addWidget(spin_box) app = QApplication(sys.argv) demo = AppDemo() demo.show() sys.exit(app.exec_()) 

In the code above, we've applied a stylesheet to the QSpinBox which adds a 2px solid red border to its up button. You can adjust the stylesheet to customize the border's appearance as per your preferences.


More Tags

react-lifecycle tabview e-commerce uninstallation ionic2 http-status-code-413 spring-rest movable exit eclipse

More Programming Guides

Other Guides

More Programming Examples