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


Qt Code:
  1. float sum = 0;
  2. float sum2 = 0;
  3.  
  4.  
  5. //do the loop thing
  6. for (int = 0; i<list_result->count(); i++) {
  7.  
  8. //get the text from each row of the QListWidget, and transform to Float (?)
  9. sum2 = ???
  10.  
  11. //sum the numbers
  12. sum = sum + sum2;
  13.  
  14. }
  15.  
  16. //show the result in an Edit by transforming into a String
  17. ed_result->setText(QString::number(sum));
To copy to clipboard, switch view to plain text mode 



Edit: Qt version 4.6.2