Hi there!

I have this toQString function
Qt Code:
  1. QString Diet::toQString()const
  2. {
  3.  
  4. QString qName(this->name.c_str());
  5. QString qUserName(this->userName.c_str());
  6. QString qDate(this->date.c_str());
  7. QString kcal;
  8. QString carb;
  9. QString protein;
  10. QString lipid;
  11.  
  12. carb.setNum(this->carb);
  13. protein.setNum((this->protein));
  14. lipid.setNum(this->lipid);
  15. kcal.setNum(this->kcal);
  16.  
  17. QString str=qUserName;
  18. str.append(" "+qDate+" "+qName+" "+protein+" "+carb+" "+lipid+" "+kcal);
  19.  
  20. return str;
  21. }
To copy to clipboard, switch view to plain text mode 
I know this function works properly as it returns the qstring I want.

Now In my other class I have this function.
Qt Code:
  1. void DH::toQString()const
  2. {
  3.  
  4. for(int i=0;i< this->nrOfDiets;i++)
  5. {
  6. this->dh[i]->toQString();
  7. }
  8. }
To copy to clipboard, switch view to plain text mode 
What I would like to accomplish with these two functions is for example when I write something like this
Qt Code:
  1. void MainWindow::on_pushButton_3_clicked()
  2. {
  3. DH dh1;
  4. ui->list2->addItem(dh1.toQString());
  5. }
To copy to clipboard, switch view to plain text mode 
the info from the array should be converted to QString then presented in the list widget, but I'm doing something worn because it crashes when I try this.

Any kind of help is appreciated.