eLancaster
25th December 2010, 16:33
I made a program that converts celsius to fahrenheit and vice versa. It consists of two sliders: sl_celsius: and sl_fheit, and two lcd displays lcd_celsius and lcd_fheit.
Moving sl_celsius displays the celsius temperature in lcd_celsius and the corresponding fahrenheit temperature in lcd_fheit. As the lcd_fheit changes, the sl_fheit also moves.
The problem is that the reverse does not occur (i.e. moving the fahrenheit slider does not cause celsius to be displayed in lcd_celsius and sl_celsius does not move either). I do not understand why this happens.
The connections are as follows:
connect(ui->sl_celsius,SIGNAL(sliderMoved(int)),ui->lcd_celsius,SLOT(display(int)));
connect(ui->sl_celsius,SIGNAL(sliderMoved(int)),this,SLOT(calc ulateFahrenheitTemperature(int)));
connect(this,SIGNAL(celsiusSliderMoved(int)),ui->lcd_fheit,SLOT(display(int)));
connect(this,SIGNAL(celsiusSliderMoved(int)),ui->sl_fheit,SLOT(setValue(int)));
connect(ui->sl_fheit,SIGNAL(sliderMoved(int)),ui->lcd_fheit,SLOT(display(int)));
connect(ui->sl_fheit,SIGNAL(sliderMoved(int)),this,SLOT(calcul ateCelsiusTemperature(int)));
connect(this,SIGNAL(fheitSliderMoved(int)),ui->lcd_celsius,SLOT(display(int)));
connect(this,SIGNAL(fheitSliderMoved(int)),ui->sl_celsius,SLOT(setValue(int)));
and these are the definitions for custom fucntions:
void TempConverter::calculateCelsiusTemperature(int temp)
{
celsius = (temp - 32)*(5/9);
emit fheitSliderMoved(celsius);
}
void TempConverter::calculateFahrenheitTemperature(int temp)
{
fahrenheit = ((temp * (9/5))+32);
emit celsiusSliderMoved(fahrenheit);
}
I'd appreciate any help, thanks!
Moving sl_celsius displays the celsius temperature in lcd_celsius and the corresponding fahrenheit temperature in lcd_fheit. As the lcd_fheit changes, the sl_fheit also moves.
The problem is that the reverse does not occur (i.e. moving the fahrenheit slider does not cause celsius to be displayed in lcd_celsius and sl_celsius does not move either). I do not understand why this happens.
The connections are as follows:
connect(ui->sl_celsius,SIGNAL(sliderMoved(int)),ui->lcd_celsius,SLOT(display(int)));
connect(ui->sl_celsius,SIGNAL(sliderMoved(int)),this,SLOT(calc ulateFahrenheitTemperature(int)));
connect(this,SIGNAL(celsiusSliderMoved(int)),ui->lcd_fheit,SLOT(display(int)));
connect(this,SIGNAL(celsiusSliderMoved(int)),ui->sl_fheit,SLOT(setValue(int)));
connect(ui->sl_fheit,SIGNAL(sliderMoved(int)),ui->lcd_fheit,SLOT(display(int)));
connect(ui->sl_fheit,SIGNAL(sliderMoved(int)),this,SLOT(calcul ateCelsiusTemperature(int)));
connect(this,SIGNAL(fheitSliderMoved(int)),ui->lcd_celsius,SLOT(display(int)));
connect(this,SIGNAL(fheitSliderMoved(int)),ui->sl_celsius,SLOT(setValue(int)));
and these are the definitions for custom fucntions:
void TempConverter::calculateCelsiusTemperature(int temp)
{
celsius = (temp - 32)*(5/9);
emit fheitSliderMoved(celsius);
}
void TempConverter::calculateFahrenheitTemperature(int temp)
{
fahrenheit = ((temp * (9/5))+32);
emit celsiusSliderMoved(fahrenheit);
}
I'd appreciate any help, thanks!