Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkDoseValueDelegate Class Reference

Item delegate for rendering and editing dose values in a QTableView. More...

#include <QmitkDoseValueDelegate.h>

Inheritance diagram for QmitkDoseValueDelegate:
Collaboration diagram for QmitkDoseValueDelegate:

Public Member Functions

 QmitkDoseValueDelegate (QObject *parent=nullptr)
 Constructor. More...
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Renders the dose value text right-aligned in the cell. More...
 
QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Creates a QDoubleSpinBox editor for editing dose values. More...
 
void setEditorData (QWidget *editor, const QModelIndex &index) const override
 Populates the editor with the current dose value from the model. More...
 
void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
 Commits the edited dose value from the spin box back to the model. More...
 

Detailed Description

Item delegate for rendering and editing dose values in a QTableView.

This delegate renders dose values right-aligned and creates a QDoubleSpinBox editor for editing. The delegate inspects Qt::UserRole+1 on the model to determine whether the dose is displayed as absolute (Gy) or relative (%). The spin box suffix and step size are adjusted accordingly.

See also
QmitkIsoDoseLevelSetModel
QmitkDoseColorDelegate
QmitkDoseVisualStyleDelegate

Definition at line 34 of file QmitkDoseValueDelegate.h.

Constructor & Destructor Documentation

◆ QmitkDoseValueDelegate()

QmitkDoseValueDelegate::QmitkDoseValueDelegate ( QObject *  parent = nullptr)
explicit

Constructor.

Parameters
[in]parentOptional parent QObject.

Member Function Documentation

◆ createEditor()

QWidget* QmitkDoseValueDelegate::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
override

Creates a QDoubleSpinBox editor for editing dose values.

The spin box is configured with appropriate suffix ("Gy" or "%"), step size, and range [0, 9999] based on whether the dose is absolute or relative.

Parameters
[in]parentThe parent widget for the editor.
[in]optionStyle options for the item.
[in]indexThe model index of the item to edit.
Returns
A QDoubleSpinBox for valid data, or a QLabel for invalid data.

◆ paint()

void QmitkDoseValueDelegate::paint ( QPainter *  painter,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
override

Renders the dose value text right-aligned in the cell.

Parameters
[in]painterThe QPainter to use for drawing.
[in]optionStyle options for the item.
[in]indexThe model index of the item to paint.

◆ setEditorData()

void QmitkDoseValueDelegate::setEditorData ( QWidget *  editor,
const QModelIndex &  index 
) const
override

Populates the editor with the current dose value from the model.

Parameters
[in,out]editorThe editor widget (QDoubleSpinBox) to populate.
[in]indexThe model index to read data from.

◆ setModelData()

void QmitkDoseValueDelegate::setModelData ( QWidget *  editor,
QAbstractItemModel *  model,
const QModelIndex &  index 
) const
override

Commits the edited dose value from the spin box back to the model.

Parameters
[in]editorThe editor widget (QDoubleSpinBox) containing the new value.
[in,out]modelThe model to write the new value to.
[in]indexThe model index of the item being edited.

The documentation for this class was generated from the following file: