Hello,

I'm developing an app that has 100 line edits.
I named them t001, t002, t003, ..., t100
I want to convert the value of each text in the line edits to double (no problem there) and save it in a vector, called t[].
I don't want to repeat the following code a hundred times over:

Qt Code:
  1. double t[100];
  2. int count1 = 0;
  3. if(ui->t001->text() != "")
  4. {
  5. t[count1] = ui->t001->text().toDouble();
  6. count1++;
  7. }
To copy to clipboard, switch view to plain text mode 

So, is there anyway I can use the name of the object as a string variable, so I can use a loop? Like:

Qt Code:
  1. double t[100];
  2. int count1 = 0;
  3. QString current_element;
  4.  
  5.  
  6. for(count1 = 0; count1 < 100; count1++)
  7. {
  8. current_element = "t" + count1+1;
  9.  
  10. if(ui->current_element->text() != "")
  11. t[count1] = ui->current_element->text().toDouble();
  12. }
To copy to clipboard, switch view to plain text mode 

edited: I know this code wouldn't work and needs adapting in at least 2 parts, but still, what I need answered is the main question in the thread.


Thanks in advance.