modules/utility/delegateComboBox_backup.py¶
Overview¶
This file contains 15 documented elements.
Classes¶
TooltipListView¶
Custom ListView that properly shows tooltips
Inherits from: QListView
Methods¶
init(self, parent)¶
Initializes a TooltipListView instance by calling the parent QListView constructor with the optional parent argument. Enables mouse tracking on the view and sets the Qt.WA_AlwaysShowToolTips attribute on the viewport to ensure tooltip events are consistently generated.
viewportEvent(self, event)¶
Handle viewport events including tooltips
TooltipComboBox¶
Custom ComboBox that shows tooltips for items in the dropdown
Inherits from: QComboBox
Methods¶
init(self, parent)¶
Initializes a TooltipComboBox instance by calling the parent QComboBox constructor with the optional parent widget. A TooltipListView instance is created and assigned as the combo box's view via setView. A default tooltip of "Click per aprire la lista" is set on the combo box itself.
addItem(self, text, userData)¶
Override to ensure we can add tooltips
showPopup(self)¶
Override to ensure view is properly configured when shown
ComboBoxDelegate¶
No description available.
A QItemDelegate subclass that renders and manages a TooltipComboBox editor within item views. It maintains a list of selectable values and an editability flag, using these to configure the combo box editor created for each cell. The delegate handles synchronisation between the editor and the underlying model via setEditorData and setModelData, matching display text to combo box entries and writing the selected text back to the model.
Inherits from: QItemDelegate
Methods¶
init(self, values, parent)¶
Initializes a ComboBoxDelegate instance by calling the parent QItemDelegate constructor with the given parent argument. If values is provided and evaluates to a truthy value, it assigns values to the instance attribute self.values, overriding the class-level default.
def_values(self, values)¶
No description available.
Sets the values attribute of the delegate to the provided values argument. This method allows updating the delegate's values after initialization, overwriting any previously assigned value. It takes a single parameter, values, and assigns it directly to self.values.
def_editable(self, editable)¶
Sets the editable attribute of the instance to the provided editable value. This method stores the given argument directly on the object, controlling whether the associated editor component is editable.
createEditor(self, parent, option, index)¶
Creates and configures a TooltipComboBox widget to serve as the delegate editor for a given cell. Populates the combo box with items from self.values and sets its size adjustment policy to QComboBox.AdjustToContents. The editability of the combo box is determined by evaluating self.editable if the attribute exists and is non-empty; otherwise, the editor defaults to non-editable.
setEditorData(self, editor, index)¶
No description available.
Populates the editor widget with data from the model at the given index. Retrieves the display text from the model using Qt.DisplayRole and locates the corresponding entry in the editor via findText; if no match is found, the index defaults to 0. Sets the editor's current selection to the resolved index using setCurrentIndex.
setModelData(self, editor, model, index)¶
No description available.
Writes data from the editor widget back to the model at the specified index. Retrieves the current text from the editor (a combo box) using currentText() and stores it in the model via model.setData(index, editor.currentText()). This method overrides the delegate's default implementation to ensure the selected text value is persisted to the underlying data model.