Hi i am having a problem and cannot figure out how to fix.

I get a list of records displayed in a listwidget, and when a user clicks on a record the below function gets the associated record ID and displays the full record details in a webview. (All this works fine)

When a user reads through the webview they can click a pushbutton to go back to the listwidget where they can click on other records in the list. The problem i am getting is, if the user clicks on the same record as before weird things start to happen.

Initially nothing happens but if i click on the search button (which selects data from database and displays in listwidget), it then takes me to webview. I suspect the itemselectionchanged needs me to select off and then on the original record or on a new unselected record.

Is there anyway around this? Any examples would really help.


Qt Code:
  1. void MainWindow::on_listWidget_itemSelectionChanged()
  2. {
  3.  
  4. int iRow = ui->listWidget->currentRow();
  5. int strID = persondata.at(iRow)->ID;
  6.  
  7. persondata.clear();
  8. persondata = dbManager->getPersonData(strID);
  9.  
  10. //Create instance
  11. PersonData* persondata3;
  12.  
  13. //Start html tags
  14. QString htmltext = "<html><body>";
  15.  
  16. //Loop through returned records
  17. foreach(persondata3,persondata)
  18. {
  19.  
  20. //Add each record to Qstring variable
  21. htmltext.append("<br>");
  22. htmltext.append(persondata3->Address);
  23.  
  24. }
  25.  
  26.  
  27. //End html tags and display in wbeview
  28. htmltext.append("</body></html>");
  29. ui->webView->setHtml(htmltext);
  30.  
  31.  
  32. //Go to where webview is displayed
  33. ui->stackedWidget->setCurrentIndex(2);
  34.  
  35. }
To copy to clipboard, switch view to plain text mode