furiousrox
31st August 2010, 05:20
Hello,
Im newbie, and I wish somebody helps me getting the text value of a Row in a QListWidget named list_result, sum it with the other values and then display on an Edit.
I need to iterate it so i can sum all the numbers in the list, but i dont know how to get the TEXT out of it... Also, I think I need to turn the text into a float type to calculate, but i can't get it working, tried many combinations of codes.... Somebody help me please :(
float sum = 0;
float sum2 = 0;
//do the loop thing
for (int = 0; i<list_result->count(); i++) {
//get the text from each row of the QListWidget, and transform to Float (?)
sum2 = ???
//sum the numbers
sum = sum + sum2;
}
//show the result in an Edit by transforming into a String
ed_result->setText(QString::number(sum));
Edit: Qt version 4.6.2
Im newbie, and I wish somebody helps me getting the text value of a Row in a QListWidget named list_result, sum it with the other values and then display on an Edit.
I need to iterate it so i can sum all the numbers in the list, but i dont know how to get the TEXT out of it... Also, I think I need to turn the text into a float type to calculate, but i can't get it working, tried many combinations of codes.... Somebody help me please :(
float sum = 0;
float sum2 = 0;
//do the loop thing
for (int = 0; i<list_result->count(); i++) {
//get the text from each row of the QListWidget, and transform to Float (?)
sum2 = ???
//sum the numbers
sum = sum + sum2;
}
//show the result in an Edit by transforming into a String
ed_result->setText(QString::number(sum));
Edit: Qt version 4.6.2