hi,

I'm trying to make a simple program that gets integers from sliders,
and compute them.

A sample of my code :

data.h
Qt Code:
  1. #include <QtGUI>
  2. #include <QObject>
  3.  
  4. #ifndef DATA_H
  5. #define DATA_H
  6. class Data : public QWidget
  7. {
  8. Q_OBJECT
  9.  
  10. public:
  11. Data(QWidget *parent = 0);
  12.  
  13. public slots:
  14. void doSum();
  15.  
  16. private:
  17. int Z0RealSliderValue;
  18. int ZLRealSliderValue;
  19.  
  20. QLineEdit *Product;
  21.  
  22. };
  23.  
  24. #endif // DATA_H
To copy to clipboard, switch view to plain text mode 

data.cpp
Qt Code:
  1. #include <QtGUI>
  2. #include "data.h"
  3.  
  4. Data::Data(QWidget *parent)
  5. {
  6.  
  7. QSlider *Z0RealInput = new QSlider(Qt::Horizontal, this);
  8. Z0RealInput->setRange(0, 150);
  9.  
  10. QSlider *ZLRealInput = new QSlider(Qt::Horizontal, this);
  11. ZLRealInput->setRange(0, 150);
  12.  
  13. Z0RealSliderValue = Z0RealInput->value();
  14. ZLRealSliderValue = ZLRealInput->value();
  15.  
  16. Product = new QLineEdit("Sum");
  17. Product->setReadOnly(true);
  18.  
  19. QPushButton *Plot = new QPushButton(tr("Plot"),this);
  20. connect(Plot, SIGNAL(clicked()), this, SLOT(doSum()));
  21.  
  22. //layout etc etc
  23. ....
  24.  
  25. }
  26.  
  27. void Data::doSum()
  28. {
  29. int Sum = 0;
  30.  
  31. Sum = ZLRealSliderValue + Z0RealSliderValue;
  32.  
  33. Product->setText(QString::number(Sum));
  34.  
  35. }
To copy to clipboard, switch view to plain text mode 

It kept returning 0.

I have tried to change setting the lineedit text with a constant string, and it worked,
so I assume there is nothing wrong with the connection.

Is it how I retrieve the value which make the code not working?

Thanks in advance.