|
def | __init__ (self, parent, item_list, data_access_role=QtCore.Qt.DisplayRole, size=QtCore.QSize(80, 50)) |
|
def | createEditor (self, parent, option, index) |
| Create for the display and interaction with the user an editor. More...
|
|
def | commitAndCloseEditor (self) |
|
def | sizeHint (self) |
|
def | setEditorData (self, editor, index) |
| Set the display of the current value of the used editor. More...
|
|
def | setModelData (self, editor, model, index) |
| Save the data of the editor to the model. More...
|
|
def | paint (self, painter, option, index) |
|
|
| editingFinished = QtCore.Signal() |
|
◆ createEditor()
def pulsed_item_delegates.ComboBoxItemDelegate.createEditor |
( |
|
self, |
|
|
|
parent, |
|
|
|
option, |
|
|
|
index |
|
) |
| |
Create for the display and interaction with the user an editor.
- Parameters
-
QtGui.QWidget | parent: The parent object (probably QTableView) |
QtGui.QStyleOptionViewItemV4 | option: This is a setting option which you can use for style configuration. |
QtCore.QModelIndex | index: That index will be passed by the model object of the QTableView to the delegated object. This index contains information about the selected current cell. |
An editor can be in principle any QWidget, which you want to use to display the current (model-)data. Therefore the editor is also a container, which handles the passed entries from the user interface and should save the data in the model object of the QTableWidget.
Do not save the created editor as a class variable! This consumes a lot of unneeded memory. It is way better to create an editor if it is needed. The inherent function closeEditor() of QStyledItemDelegate takes care of closing and destroying the editor for you, if it is not needed any longer.
◆ setEditorData()
def pulsed_item_delegates.ComboBoxItemDelegate.setEditorData |
( |
|
self, |
|
|
|
editor, |
|
|
|
index |
|
) |
| |
Set the display of the current value of the used editor.
- Parameters
-
QComboBox | editor: QObject which was created in createEditor function, here a QCombobox. |
QtCore.QModelIndex | index: explained in createEditor function. |
◆ setModelData()
def pulsed_item_delegates.ComboBoxItemDelegate.setModelData |
( |
|
self, |
|
|
|
editor, |
|
|
|
model, |
|
|
|
index |
|
) |
| |
Save the data of the editor to the model.
- Parameters
-
QComboBox | editor: QObject which was created in createEditor function, here a QCombobox. |
QtCore.QAbstractTableModel | model: That is the object which contains the data model. |
QtCore.QModelIndex | index: explained in createEditor function. |
Before the editor is destroyed the current selection should be saved in the data model. The setModelData() function reads the content of the editor, and writes it to the model. Furthermore here the postprocessing of the data can happen, where the data can be manipulated for the model.
The documentation for this class was generated from the following file:
- gui/pulsed/pulsed_item_delegates.py