Computer Assited Medical Intervention Tool Kit  version 4.1
Signals | Public Member Functions | Protected Slots | Private Member Functions | Private Attributes | List of all members
camitk::SliderTextWidget Class Reference

This widget allows you to use a slider with a lineedit in a Dialog Box. More...

#include <SliderTextWidget.h>

Inherits QWidget.

Signals

void valueChanged ()
 Signal emitted when the value has changed (either directly using the slider or when the user pressed return) More...
 

Public Member Functions

double getValue () const
 Get the current value. More...
 
void init (double min=0.0, double max=100.0, double value=50.0)
 initialize slider and lineedit with the label, min, max, and current value Default values are min=0, max=100 and current value=50 More...
 
void setName (const QString &)
 set the text label (name of the manipulated data) More...
 
void setValue (const double, bool emitValueChanged=false)
 Update slider and lineedit GUI, emit the valueChanged signal only if the boolean is true (default=no) More...
 
 SliderTextWidget (QWidget *parent=nullptr, Qt::WindowFlags fl=nullptr)
 Default constructor, name is automatically used as the text label. More...
 
 ~SliderTextWidget () override
 Destructor. More...
 

Protected Slots

void returnPressed ()
 when the user press return in the line edit More...
 
void textModified (const QString &)
 When the user change the text. More...
 
void valueChanged (int)
 Update the value of the lineedit when slider moves. More...
 

Private Member Functions

double sliderToValue (const int)
 convert from slider value to double More...
 
void updateLineEdit ()
 Update the line edit value. More...
 
void updateSlider ()
 update the slider position More...
 
int valueToSlider (const double)
 convert from value to slider More...
 

Private Attributes

QColor bgColor
 the line edit bg color More...
 
QLabel * label
 the text label More...
 
QLineEdit * lineEdit
 the line edit More...
 
double max
 the max real value More...
 
double min
 the min real value More...
 
QSlider * slider
 the slider More...
 
double value
 the current value More...
 

Detailed Description

This widget allows you to use a slider with a lineedit in a Dialog Box.

The [min,max] interval is divided by 100 line steps (10 page steps), the slider controling the variation in percentage.

1 label is used to give the parameter a name (default is objectName())

Your own initialization: in YourDialog class,you can init a SliderTextWidget using setText(..) and init(..).

In line edit, if the value is superior or inferior than the initial bounds, the bounds are automatically updated.

Constructor & Destructor Documentation

◆ SliderTextWidget()

camitk::SliderTextWidget::SliderTextWidget ( QWidget *  parent = nullptr,
Qt::WindowFlags  fl = nullptr 
)

Default constructor, name is automatically used as the text label.

References bgColor, label, lineEdit, max, min, returnPressed(), setName(), slider, textModified(), updateLineEdit(), updateSlider(), value, and valueChanged().

◆ ~SliderTextWidget()

camitk::SliderTextWidget::~SliderTextWidget ( )
override

Destructor.

Member Function Documentation

◆ getValue()

double camitk::SliderTextWidget::getValue ( ) const
inline

Get the current value.

◆ init()

void camitk::SliderTextWidget::init ( double  min = 0.0,
double  max = 100.0,
double  value = 50.0 
)

initialize slider and lineedit with the label, min, max, and current value Default values are min=0, max=100 and current value=50

References max, min, updateLineEdit(), updateSlider(), and value.

◆ returnPressed

void camitk::SliderTextWidget::returnPressed ( )
protectedslot

when the user press return in the line edit

References bgColor, lineEdit, max, min, updateSlider(), value, and valueChanged().

Referenced by SliderTextWidget().

◆ setName()

void camitk::SliderTextWidget::setName ( const QString &  name)

set the text label (name of the manipulated data)

References label.

Referenced by SliderTextWidget().

◆ setValue()

void camitk::SliderTextWidget::setValue ( const double  val,
bool  emitValueChanged = false 
)

Update slider and lineedit GUI, emit the valueChanged signal only if the boolean is true (default=no)

References updateLineEdit(), updateSlider(), value, and valueChanged().

◆ sliderToValue()

double camitk::SliderTextWidget::sliderToValue ( const int  s)
private

convert from slider value to double

References max, and min.

Referenced by valueChanged().

◆ textModified

void camitk::SliderTextWidget::textModified ( const QString &  )
protectedslot

When the user change the text.

References lineEdit.

Referenced by SliderTextWidget().

◆ updateLineEdit()

void camitk::SliderTextWidget::updateLineEdit ( )
private

Update the line edit value.

References lineEdit, and value.

Referenced by init(), setValue(), SliderTextWidget(), and valueChanged().

◆ updateSlider()

void camitk::SliderTextWidget::updateSlider ( )
private

update the slider position

References slider, value, and valueToSlider().

Referenced by init(), returnPressed(), setValue(), and SliderTextWidget().

◆ valueChanged [1/2]

void camitk::SliderTextWidget::valueChanged ( )
signal

Signal emitted when the value has changed (either directly using the slider or when the user pressed return)

Referenced by returnPressed(), setValue(), SliderTextWidget(), and valueChanged().

◆ valueChanged [2/2]

void camitk::SliderTextWidget::valueChanged ( int  val)
protectedslot

Update the value of the lineedit when slider moves.

References sliderToValue(), updateLineEdit(), value, and valueChanged().

◆ valueToSlider()

int camitk::SliderTextWidget::valueToSlider ( const double  v)
private

convert from value to slider

References max, and min.

Referenced by updateSlider().

Member Data Documentation

◆ bgColor

QColor camitk::SliderTextWidget::bgColor
private

the line edit bg color

Referenced by returnPressed(), and SliderTextWidget().

◆ label

QLabel* camitk::SliderTextWidget::label
private

the text label

Referenced by setName(), and SliderTextWidget().

◆ lineEdit

QLineEdit* camitk::SliderTextWidget::lineEdit
private

◆ max

double camitk::SliderTextWidget::max
private

the max real value

Referenced by init(), returnPressed(), SliderTextWidget(), sliderToValue(), and valueToSlider().

◆ min

double camitk::SliderTextWidget::min
private

the min real value

Referenced by init(), returnPressed(), SliderTextWidget(), sliderToValue(), and valueToSlider().

◆ slider

QSlider* camitk::SliderTextWidget::slider
private

the slider

Referenced by SliderTextWidget(), and updateSlider().

◆ value

double camitk::SliderTextWidget::value
private

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