Hi there!
I have this toQString function
{
QString qUserName
(this
->userName.
c_str());
carb.setNum(this->carb);
protein.setNum((this->protein));
lipid.setNum(this->lipid);
kcal.setNum(this->kcal);
str.append(" "+qDate+" "+qName+" "+protein+" "+carb+" "+lipid+" "+kcal);
return str;
}
QString Diet::toQString()const
{
QString qName(this->name.c_str());
QString qUserName(this->userName.c_str());
QString qDate(this->date.c_str());
QString kcal;
QString carb;
QString protein;
QString lipid;
carb.setNum(this->carb);
protein.setNum((this->protein));
lipid.setNum(this->lipid);
kcal.setNum(this->kcal);
QString str=qUserName;
str.append(" "+qDate+" "+qName+" "+protein+" "+carb+" "+lipid+" "+kcal);
return str;
}
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.
void DH::toQString()const
{
for(int i=0;i< this->nrOfDiets;i++)
{
this->dh[i]->toQString();
}
}
void DH::toQString()const
{
for(int i=0;i< this->nrOfDiets;i++)
{
this->dh[i]->toQString();
}
}
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
void MainWindow::on_pushButton_3_clicked()
{
DH dh1;
ui->list2->addItem(dh1.toQString());
}
void MainWindow::on_pushButton_3_clicked()
{
DH dh1;
ui->list2->addItem(dh1.toQString());
}
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.
Bookmarks