Reputation: 5422
I have a program in which I want to use QString in a Qlabel :
text1->setText(QString("Actual value of Threshold: %1 mV").arg(slider->value()*2.745098));
well this work fine, but I would like to get integer value like 100 mV instead of 100.84654mV any Idea how can I do.
silder->value();
is given an integer value back. and casting like :
text1->setText(QString("Actual value of Threshold: %1 mV").arg((int)slider->value()*2.745098));
Upvotes: 0
Views: 382
Reputation: 9853
int value = qRound(slider->value() * 2.745098);
QString text = QString("Actual value of Threshold: %1 mV").arg(value);
Upvotes: 0
Reputation: 1856
You should cast the calculated value to int.
text1->setText(QString("Actual value of Threshold: %1 mV").arg((int)(slider->value()*2.745098)));
Upvotes: 1