Computer Assited Medical Intervention Tool Kit  version 5.0
camitk::SliderTextWidget Class Reference

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. More...

#include <SliderTextWidget.h>

+ Inheritance diagram for camitk::SliderTextWidget:
+ Collaboration diagram for camitk::SliderTextWidget:

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=Qt::WindowFlags())
 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 (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 = Qt::WindowFlags() 
)

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

◆ ~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 bgColor, lineEdit, min, and value.

◆ returnPressed

void camitk::SliderTextWidget::returnPressed ( )
protectedslot

when the user press return in the line edit

References lineEdit.

◆ setName()

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

set the text label (name of the manipulated data)

◆ 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)

◆ sliderToValue()

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

convert from slider value to double

◆ textModified

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

When the user change the text.

◆ updateLineEdit()

void camitk::SliderTextWidget::updateLineEdit ( )
private

Update the line edit value.

References slider.

◆ updateSlider()

void camitk::SliderTextWidget::updateSlider ( )
private

update the slider position

◆ 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)

◆ valueChanged [2/2]

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

Update the value of the lineedit when slider moves.

◆ valueToSlider()

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

convert from value to slider

Member Data Documentation

◆ bgColor

QColor camitk::SliderTextWidget::bgColor
private

the line edit bg color

Referenced by init().

◆ label

QLabel* camitk::SliderTextWidget::label
private

the text label

◆ lineEdit

QLineEdit* camitk::SliderTextWidget::lineEdit
private

the line edit

Referenced by init(), and returnPressed().

◆ max

double camitk::SliderTextWidget::max
private

the max real value

◆ min

double camitk::SliderTextWidget::min
private

the min real value

Referenced by init().

◆ slider

QSlider* camitk::SliderTextWidget::slider
private

the slider

Referenced by updateLineEdit().

◆ value

double camitk::SliderTextWidget::value
private

the current value

Referenced by init().


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