Results 1 to 3 of 3

Thread: QList.replace continuous error

  1. #1
    Join Date
    Jan 2012
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QList.replace continuous error

    Hello,

    I've problems with my application, see, I've a MainWindow which contains a QListWidget and a variable QList<MyStruct> as public. There's a PushButton which opens a new Window, which I can add items to my QList and show them into my QListWidget, but the problem is that I've another PushButton, to edit an existing item, I seem to be allowed to parse the item (struct) successfully to the second Window, but trying to save that item back (replace) crashes my app with a debugger error that says "The inferior stopped because it received a signal from the Operating System".

    This is the code I'm using;


    Qt Code:
    1. //Edit Conversation
    2. void MainWindow::on_pushButton_4_clicked()
    3. {
    4.  
    5. QModelIndexList indexes = ui->listTalk->selectionModel()->selectedIndexes();
    6. ConversationWindow *dlg = new ConversationWindow(this);
    7. dlg->isEdit = true;
    8.  
    9. dlg->editConversation((quint8)indexes.at(0).row(), TalkList.at(indexes.at(0).row()));
    10.  
    11. if (indexes.count() > 0)
    12. dlg->show();
    13. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // Add or Edit existing conversation
    2. void ConversationWindow::on_pushButton_2_clicked()
    3. {
    4. ConversationItem item;
    5.  
    6. if (!isEdit)
    7. {
    8. item.Key1_t = ui->lineEdit->text();
    9. item.Key2_t = ui->lineEdit_2->text();
    10. item.Key3_t = ui->lineEdit_3->text();
    11. item.getState = ui->checkBox->checkState();
    12. item.setState = ui->checkBox_2->checkState();
    13. item.getStateValue = ui->spinBox->value();
    14. item.setStateValue = ui->spinBox_2->value();
    15. item.JustAnswer = ui->checkBox_3->checkState();
    16. item.Answer_t = ui->lineEdit_4->text();
    17. item.isScript = ui->checkBox_5->checkState();
    18. item.Script_t << ui->textEdit->toPlainText();
    19.  
    20. list->append(item);
    21.  
    22. close();
    23.  
    24. window->DrawTalk();
    25. } else {
    26. item.Key1_t = ui->lineEdit->text();
    27. item.Key2_t = ui->lineEdit_2->text();
    28. item.Key3_t = ui->lineEdit_3->text();
    29. item.getState = ui->checkBox->checkState();
    30. item.setState = ui->checkBox_2->checkState();
    31. item.getStateValue = ui->spinBox->value();
    32. item.setStateValue = ui->spinBox_2->value();
    33. item.JustAnswer = ui->checkBox_3->checkState();
    34. item.Answer_t = ui->lineEdit_4->text();
    35. item.isScript = ui->checkBox_5->checkState();
    36. item.Script_t << ui->textEdit->toPlainText();
    37.  
    38. // I've tried with replace but same error appears.
    39. list->removeAt(editIndex);
    40. list->insert(editIndex, item);
    41.  
    42. isEdit = false;
    43. }
    44. }
    To copy to clipboard, switch view to plain text mode 

    I'm parsing the item index correctly checked with debug.
    Please help me )

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QList.replace continuous error

    Run the program in a debugger. When it crashes inspect the backtrace and the value of variables in use at the time.

    What set "list" in ConversationWindow and what is its value? I am betting it is null or invalid.

  3. The following user says thank you to ChrisW67 for this useful post:

    Jonathan Maen (23rd January 2012)

  4. #3
    Join Date
    Jan 2012
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QList.replace continuous error

    Quote Originally Posted by ChrisW67 View Post
    Run the program in a debugger. When it crashes inspect the backtrace and the value of variables in use at the time.

    What set "list" in ConversationWindow and what is its value? I am betting it is null or invalid.
    Thank you, the error was that I forgot to parse my list from MainWindow to EditWindow pointer variable.

    I'm still learning second day with Qt & C++ lol.

Similar Threads

  1. Replies: 4
    Last Post: 20th August 2010, 13:54
  2. qlist error
    By knishaq in forum Qt Programming
    Replies: 2
    Last Post: 20th December 2009, 13:07
  3. Error with a QList<QImage>
    By Sirithang in forum Newbie
    Replies: 0
    Last Post: 15th November 2009, 15:37
  4. QList: Out of Memory Error
    By ignoramous in forum Newbie
    Replies: 4
    Last Post: 18th May 2009, 09:34
  5. replace string in QList<QStringList>
    By estanisgeyer in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2008, 17:40

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.