babygal
13th July 2010, 10:26
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:
QDoubleSpinBox *myspinBox;
QLabel *labelText;
QObject::connect(myspinBox,SIGNAL(valueChanged(QSt ring)),this,SLOT(setnewText(QString)));
void myDialog::setnewText(QString newinput)
{
newinputvalue = newinput;
multiplication();
}
void myDialog::multiplication()
{
float floatnum ;
float floatmultiplywith;
bool ok;
floatnum = newinputvalue .toFloat(&ok);
QString newValue = QString::number(floatmultiplywith*floatnum );
labelText->setText(newValue );
}
displayed as output in a label. but the value is 0(incorrect).
Code:
QDoubleSpinBox *myspinBox;
QLabel *labelText;
QObject::connect(myspinBox,SIGNAL(valueChanged(QSt ring)),this,SLOT(setnewText(QString)));
void myDialog::setnewText(QString newinput)
{
newinputvalue = newinput;
multiplication();
}
void myDialog::multiplication()
{
float floatnum ;
float floatmultiplywith;
bool ok;
floatnum = newinputvalue .toFloat(&ok);
QString newValue = QString::number(floatmultiplywith*floatnum );
labelText->setText(newValue );
}