add styled delegates to comboboxes

This commit is contained in:
iLLiCiTiT 2021-11-12 11:06:36 +01:00
parent c9228d74a0
commit 5e2e818db2
2 changed files with 8 additions and 0 deletions

View file

@ -456,6 +456,8 @@ class _SiteCombobox(QtWidgets.QWidget):
self
)
combobox_input = QtWidgets.QComboBox(self)
combobox_delegate = QtWidgets.QStyledItemDelegate()
combobox_input.setItemDelegate(combobox_delegate)
main_layout = QtWidgets.QHBoxLayout(self)
main_layout.addWidget(label_widget)
@ -464,6 +466,7 @@ class _SiteCombobox(QtWidgets.QWidget):
combobox_input.currentIndexChanged.connect(self._on_index_change)
self.label_widget = label_widget
self.combobox_input = combobox_input
self._combobox_delegate = combobox_delegate
def _set_current_text(self, text):
index = None

View file

@ -132,9 +132,14 @@ class SettingsComboBox(QtWidgets.QComboBox):
def __init__(self, *args, **kwargs):
super(SettingsComboBox, self).__init__(*args, **kwargs)
delegate = QtWidgets.QStyledItemDelegate()
self.setItemDelegate(delegate)
self.currentIndexChanged.connect(self._on_change)
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self._delegate = delegate
def wheelEvent(self, event):
if self.hasFocus():
return super(SettingsComboBox, self).wheelEvent(event)