Results 1 to 3 of 3

Thread: ListWidget_ItemSelectionChanged cannot be run more than once?

  1. #1
    Join Date
    Nov 2010
    Posts
    22
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default ListWidget_ItemSelectionChanged cannot be run more than once?

    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 

  2. #2
    Join Date
    Nov 2010
    Posts
    22
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: ListWidget_ItemSelectionChanged cannot be run more than once?

    I ma having another problem with this function. If i clicked on a record in the listwidget then view webview and then go back to listwidget list and repeat process on another 5 different records the application crashes.

  3. #3
    Join Date
    Nov 2010
    Posts
    22
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: ListWidget_ItemSelectionChanged cannot be run more than once?

    Identified the problem,
    Qt Code:
    1. int strID = persondata.at(iRow)->ID;
    To copy to clipboard, switch view to plain text mode 
    was not able to get an updated value after the initial first click selection this was due to the persondata.clear();

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.