Whenever I open the QColorDialog, the values in spinbuttons (Right Bottom) are not shown properly.
-
Python version : 3.12.4
-
PySide6 Version : 6.7.2
[ Test Code ]
from PySide6.QtWidgets import QApplication, QLayout, QWidget, QGridLayout, QPushButton, QColorDialog
from PySide6.QtGui import QColor
import sys
class myWidget(QWidget):
def __init__(self):
super().__init__()
layout = QGridLayout()
self.button = QPushButton("Color")
self.button.clicked.connect(self.set_button_color)
layout.addWidget(self.button)
self.setLayout(layout)
self.setWindowTitle("Test")
self.show()
def set_button_color(self):
dialog = QColorDialog()
dialog.setSizeGripEnabled(True)
dialog.layout().setSizeConstraint(QLayout.SetNoConstraint)
color = dialog.getColor()
if QColor.isValid(color):
print("Selected Color Information:", color.name())
self.button.setStyleSheet("background-color: %s;"%color.name())
app = QApplication.instance()
if not app:
app = QApplication(sys.argv)
myApp = myWidget()
sys.exit(app.exec())
New contributor
user27451999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3