spinbox reads value input by user. then the value is multiplied with float value .and
displayed as output in a label. but the value is 0(incorrect).

Code:

Qt Code:
  1. QDoubleSpinBox *myspinBox;
  2. QLabel *labelText;
  3.  
  4.  
  5. QObject::connect(myspinBox,SIGNAL(valueChanged(QString)),this,SLOT(setnewText(QString)));
  6.  
  7. void myDialog::setnewText(QString newinput)
  8. {
  9. newinputvalue = newinput;
  10. multiplication();
  11.  
  12. }
  13.  
  14. void myDialog::multiplication()
  15. {
  16. float floatnum ;
  17. float floatmultiplywith;
  18. bool ok;
  19.  
  20. floatnum = newinputvalue .toFloat(&ok);
  21.  
  22. QString newValue = QString::number(floatmultiplywith*floatnum );
  23. labelText->setText(newValue );
  24.  
  25. }
To copy to clipboard, switch view to plain text mode