Quote Originally Posted by jins View Post
Thank you very much for replying. I have tried adding the above code and i get an error class QListWidgeItem has no member named 'ID'
Sorry, there is a typo in my code, use this one:
Qt Code:
  1. void MainWindow::on_pushButton1_clicked()
  2. {
  3.  
  4. ui->listWidget->clear();
  5. persondata.clear();
  6. persondata = dbManager->getPerson();
  7.  
  8. PersonData* persondata2;
  9.  
  10. foreach(persondata2,persondata)
  11. {
  12. QListWidgeItem *item = new QListWidgeItem(persondata2->FIRSTNAME);
  13. item->setData(Qt::UserRole, QVariant(persondata2->ID));
  14. ui->listWidget->addItem(item);
  15. }
  16.  
  17. }
To copy to clipboard, switch view to plain text mode