Always use scrollable combo box and manually update the style sheet in build settings instead

This commit is contained in:
Veronica Berglyd Olsen
2025-10-27 20:01:25 +01:00
parent cd8cc81b5f
commit a8a6d199d1
4 changed files with 18 additions and 14 deletions
+8 -7
View File
@@ -125,16 +125,11 @@ class NComboBox(QComboBox):
window of many widgets.
"""
def __init__(
self, parent: QWidget | None = None, maxItems: int = 15, scrollable: bool = False
) -> None:
def __init__(self, parent: QWidget | None = None, maxItems: int = 15) -> None:
super().__init__(parent=parent)
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
self.setMaxVisibleItems(maxItems)
if scrollable:
# The style sheet disables Fusion style pop-up mode on some
# platforms and allows for scrolling of long lists of items
self.setStyleSheet("QComboBox {combobox-popup: 0;}")
self.updateStyle()
def wheelEvent(self, event: QWheelEvent) -> None:
"""Only capture the mouse wheel if the widget has focus."""
@@ -148,6 +143,12 @@ class NComboBox(QComboBox):
idx = self.findData(data)
self.setCurrentIndex(self.findData(default) if idx < 0 else idx)
def updateStyle(self) -> None:
"""Update the style sheet."""
# The style sheet disables Fusion style pop-up mode on some
# platforms and allows for scrolling of long lists of items
self.setStyleSheet("QComboBox {combobox-popup: 0;}")
class NSpinBox(QSpinBox):
"""Custom: Modified QSpinBox.