Qudi
Public Member Functions | Static Public Attributes | List of all members
pulsed_item_delegates.DigitalStatesItemDelegate Class Reference
Inheritance diagram for pulsed_item_delegates.DigitalStatesItemDelegate:
Inheritance graph
[legend]
Collaboration diagram for pulsed_item_delegates.DigitalStatesItemDelegate:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, parent, 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, option, index)
 
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)
 

Static Public Attributes

 editingFinished = QtCore.Signal()
 

Member Function Documentation

◆ createEditor()

def pulsed_item_delegates.DigitalStatesItemDelegate.createEditor (   self,
  parent,
  option,
  index 
)

Create for the display and interaction with the user an editor.

Parameters
QtGui.QWidgetparent: The parent object, here QTableWidget
QtGui.QStyleOptionViewItemV4option: This is a setting option which you can use for style configuration.
QtCore.QModelIndexindex: That index will be passed by the model object of the QTableWidget 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.DigitalStatesItemDelegate.setEditorData (   self,
  editor,
  index 
)

Set the display of the current value of the used editor.

Parameters
DigitalChannelsWidgeteditor: QObject which was created in createEditor function, here a DigitalChannelsWidget.
QtCore.QModelIndexindex: 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.DigitalStatesItemDelegate.setModelData (   self,
  editor,
  model,
  index 
)

Save the data of the editor to the model.

Parameters
DigitalChannelsWidgeteditor: QObject which was created in createEditor function, here a DigitalChannelsWidget.
QtCore.QAbstractTableModelmodel: That is the object which contains the data model.
QtCore.QModelIndexindex: 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: