Item delegate for rendering and editing dose values in a QTableView.
More...
#include <QmitkDoseValueDelegate.h>
|
| | 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...
|
| |
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.
◆ QmitkDoseValueDelegate()
| QmitkDoseValueDelegate::QmitkDoseValueDelegate |
( |
QObject * |
parent = nullptr | ) |
|
|
explicit |
Constructor.
- Parameters
-
| [in] | parent | Optional parent QObject. |
◆ 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] | parent | The parent widget for the editor. |
| [in] | option | Style options for the item. |
| [in] | index | The 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] | painter | The QPainter to use for drawing. |
| [in] | option | Style options for the item. |
| [in] | index | The 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] | editor | The editor widget (QDoubleSpinBox) to populate. |
| [in] | index | The 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] | editor | The editor widget (QDoubleSpinBox) containing the new value. |
| [in,out] | model | The model to write the new value to. |
| [in] | index | The model index of the item being edited. |
The documentation for this class was generated from the following file: