BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DoubleLineEdit Class Reference

Description

LineEdit to edit values in a scientific notation, operating on a DoubleDescriptor.

In the future it can be enhanced to support units. At the moment, no DoubleDescriptor with units is used with a DoubleLineEdit, therefore the handling of units is not implemented yet. Only the naming is prepared already (also to have a naming alike to DoubleSpinBox).

Definition at line 28 of file DoubleLineEdit.h.

Inheritance diagram for DoubleLineEdit:
[legend]
Collaboration diagram for DoubleLineEdit:
[legend]

Signals

void baseValueChanged (double newBaseValue)
 Emitted whenever the value changes. More...
 

Public Member Functions

 DoubleLineEdit (QWidget *parent, const DoubleDescriptor &d)
 
void setBaseValue (double baseValue)
 Set the base value (unit is the one of the contained descriptor). More...
 
const DoubleDescriptor & valueDescriptor () const
 The descriptor on which this line edit operates. More...
 

Private Slots

void onEditingFinished ()
 

Private Attributes

QDoubleValidator * m_validator
 
DoubleDescriptor m_valueDescriptor
 

Constructor & Destructor Documentation

◆ DoubleLineEdit()

DoubleLineEdit::DoubleLineEdit ( QWidget *  parent,
const DoubleDescriptor &  d 
)

Definition at line 18 of file DoubleLineEdit.cpp.

19  : QLineEdit(parent)
21 {
22  m_validator = new QDoubleValidator(0.0, 1e+200, 1000, this);
23  m_validator->setNotation(QDoubleValidator::ScientificNotation);
24  const double minimum =
25  d.limits.hasLowerLimit() ? std::max(d.limits.lowerLimit(), -1e+200) : -1e+200;
26  const double maximum =
27  d.limits.hasUpperLimit() ? std::min(d.limits.upperLimit(), +1e+200) : +1e+200;
28  m_validator->setRange(minimum, maximum, 1000);
29  setValidator(m_validator);
30 
32 
33  connect(this, &QLineEdit::editingFinished, this, &DoubleLineEdit::onEditingFinished);
34 }
RealLimits limits
Limits of the value.
function< double()> get
function to get the current value
void setBaseValue(double baseValue)
Set the base value (unit is the one of the contained descriptor).
QDoubleValidator * m_validator
void onEditingFinished()
DoubleDescriptor m_valueDescriptor

References DoubleDescriptor::get, DoubleDescriptor::limits, m_validator, m_valueDescriptor, onEditingFinished(), and setBaseValue().

Here is the call graph for this function:

Member Function Documentation

◆ baseValueChanged

void DoubleLineEdit::baseValueChanged ( double  newBaseValue)
signal

Emitted whenever the value changes.

newBaseValue is in the unit of the valueDescriptor.

Referenced by MaterialInplaceForm::createWidgets(), and onEditingFinished().

◆ onEditingFinished

void DoubleLineEdit::onEditingFinished ( )
privateslot

Definition at line 46 of file DoubleLineEdit.cpp.

47 {
48  const double new_value = text().toDouble();
49  if (new_value != m_valueDescriptor.get())
50  emit baseValueChanged(new_value);
51 }
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.

References baseValueChanged(), DoubleDescriptor::get, and m_valueDescriptor.

Referenced by DoubleLineEdit().

◆ setBaseValue()

void DoubleLineEdit::setBaseValue ( double  baseValue)

Set the base value (unit is the one of the contained descriptor).

Definition at line 36 of file DoubleLineEdit.cpp.

37 {
38  setText(QString::number(baseValue, 'g'));
39 }

Referenced by DoubleLineEdit().

◆ valueDescriptor()

const DoubleDescriptor & DoubleLineEdit::valueDescriptor ( ) const

The descriptor on which this line edit operates.

Definition at line 41 of file DoubleLineEdit.cpp.

42 {
43  return m_valueDescriptor;
44 }

References m_valueDescriptor.

Member Data Documentation

◆ m_validator

QDoubleValidator* DoubleLineEdit::m_validator
private

Definition at line 49 of file DoubleLineEdit.h.

Referenced by DoubleLineEdit().

◆ m_valueDescriptor

DoubleDescriptor DoubleLineEdit::m_valueDescriptor
private

Definition at line 50 of file DoubleLineEdit.h.

Referenced by DoubleLineEdit(), onEditingFinished(), and valueDescriptor().


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