|
def | __init__ (self, parent, item_dict=None, data_access_role=QtCore.Qt.DisplayRole) |
|
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() |
|
◆ __init__()
def pulsed_item_delegates.SpinBoxItemDelegate.__init__ |
( |
|
self, |
|
|
|
parent, |
|
|
|
item_dict = None , |
|
|
|
data_access_role = QtCore.Qt.DisplayRole |
|
) |
| |
- Parameters
-
QWidget | parent: the parent QWidget which hosts this child widget |
dict | item_dict: dict with the following keys which give informations about the current 'unit', 'init_val', 'min', 'max', 'view_stepsize', 'dec', 'unit_prefix' |
◆ createEditor()
def pulsed_item_delegates.SpinBoxItemDelegate.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 like a container, which handles the passed entries from the user interface and should save the data to the model object of the QTableWidget. The setEditorData function reads data from the model.
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.SpinBoxItemDelegate.setEditorData |
( |
|
self, |
|
|
|
editor, |
|
|
|
index |
|
) |
| |
Set the display of the current value of the used editor.
- Parameters
-
ScienDSpinBox | editor: QObject which was created in createEditor function, here a ScienDSpinBox. |
QtCore.QModelIndex | index: explained in createEditor function. |
This function converts the passed data to an value, which can be understood by the editor.
◆ setModelData()
def pulsed_item_delegates.SpinBoxItemDelegate.setModelData |
( |
|
self, |
|
|
|
editor, |
|
|
|
model, |
|
|
|
index |
|
) |
| |
Save the data of the editor to the model.
- Parameters
-
ScienDSpinBox | editor: QObject which was created in createEditor function, here a ScienDSpinBox. |
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 underlying 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