jins
28th November 2010, 19:41
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.
void MainWindow::on_listWidget_itemSelectionChanged()
{
int iRow = ui->listWidget->currentRow();
int strID = persondata.at(iRow)->ID;
persondata.clear();
persondata = dbManager->getPersonData(strID);
//Create instance
PersonData* persondata3;
//Start html tags
QString htmltext = "<html><body>";
//Loop through returned records
foreach(persondata3,persondata)
{
//Add each record to Qstring variable
htmltext.append("<br>");
htmltext.append(persondata3->Address);
}
//End html tags and display in wbeview
htmltext.append("</body></html>");
ui->webView->setHtml(htmltext);
//Go to where webview is displayed
ui->stackedWidget->setCurrentIndex(2);
}
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.
void MainWindow::on_listWidget_itemSelectionChanged()
{
int iRow = ui->listWidget->currentRow();
int strID = persondata.at(iRow)->ID;
persondata.clear();
persondata = dbManager->getPersonData(strID);
//Create instance
PersonData* persondata3;
//Start html tags
QString htmltext = "<html><body>";
//Loop through returned records
foreach(persondata3,persondata)
{
//Add each record to Qstring variable
htmltext.append("<br>");
htmltext.append(persondata3->Address);
}
//End html tags and display in wbeview
htmltext.append("</body></html>");
ui->webView->setHtml(htmltext);
//Go to where webview is displayed
ui->stackedWidget->setCurrentIndex(2);
}