NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
NumericDelegate Class Reference

The NumericDelegate class provides a double spin box editor for numeric data in a view. More...

#include <numericdelegate.h>

Inheritance diagram for NumericDelegate:

Public Member Functions

 NumericDelegate (QWidget *parent=nullptr, double maxValue=1000000000.0, double minValue=-1000000000.0, int decimals=3, double stepSize=0.1, double value=0)
 Constructor for the NumericDelegate class.
 
QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Creates an editor widget for the given parent, style option, and model index.
 
void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
 Sets the model data based on the data of the editor widget.
 

Detailed Description

The NumericDelegate class provides a double spin box editor for numeric data in a view.

Constructor & Destructor Documentation

◆ NumericDelegate()

NumericDelegate::NumericDelegate ( QWidget *  parent = nullptr,
double  maxValue = 1000000000.0,
double  minValue = -1000000000.0,
int  decimals = 3,
double  stepSize = 0.1,
double  value = 0 
)
inline

Constructor for the NumericDelegate class.

Parameters
parentThe parent widget.
maxValueThe maximum value for the double spin box.
minValueThe minimum value for the double spin box.
decimalsThe number of decimal places for the double spin box.
stepSizeThe step size for the double spin box.

Member Function Documentation

◆ createEditor()

QWidget * NumericDelegate::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
inlineoverride

Creates an editor widget for the given parent, style option, and model index.

Parameters
parentThe parent widget.
optionThe style options for the item.
indexThe model index of the item.
Returns
The created editor widget.

◆ setModelData()

void NumericDelegate::setModelData ( QWidget *  editor,
QAbstractItemModel *  model,
const QModelIndex &  index 
) const
inlineoverride

Sets the model data based on the data of the editor widget.

Parameters
editorThe editor widget.
modelThe abstract item model.
indexThe model index of the item.