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;
//Edit Conversation
void MainWindow::on_pushButton_4_clicked()
{
QModelIndexList indexes = ui->listTalk->selectionModel()->selectedIndexes();
ConversationWindow *dlg = new ConversationWindow(this);
dlg->isEdit = true;
dlg->editConversation((quint8)indexes.at(0).row(), TalkList.at(indexes.at(0).row()));
if (indexes.count() > 0)
dlg->show();
}
//Edit Conversation
void MainWindow::on_pushButton_4_clicked()
{
QModelIndexList indexes = ui->listTalk->selectionModel()->selectedIndexes();
ConversationWindow *dlg = new ConversationWindow(this);
dlg->isEdit = true;
dlg->editConversation((quint8)indexes.at(0).row(), TalkList.at(indexes.at(0).row()));
if (indexes.count() > 0)
dlg->show();
}
To copy to clipboard, switch view to plain text mode
// Add or Edit existing conversation
void ConversationWindow::on_pushButton_2_clicked()
{
ConversationItem item;
if (!isEdit)
{
item.Key1_t = ui->lineEdit->text();
item.Key2_t = ui->lineEdit_2->text();
item.Key3_t = ui->lineEdit_3->text();
item.getState = ui->checkBox->checkState();
item.setState = ui->checkBox_2->checkState();
item.getStateValue = ui->spinBox->value();
item.setStateValue = ui->spinBox_2->value();
item.JustAnswer = ui->checkBox_3->checkState();
item.Answer_t = ui->lineEdit_4->text();
item.isScript = ui->checkBox_5->checkState();
item.Script_t << ui->textEdit->toPlainText();
list->append(item);
close();
window->DrawTalk();
} else {
item.Key1_t = ui->lineEdit->text();
item.Key2_t = ui->lineEdit_2->text();
item.Key3_t = ui->lineEdit_3->text();
item.getState = ui->checkBox->checkState();
item.setState = ui->checkBox_2->checkState();
item.getStateValue = ui->spinBox->value();
item.setStateValue = ui->spinBox_2->value();
item.JustAnswer = ui->checkBox_3->checkState();
item.Answer_t = ui->lineEdit_4->text();
item.isScript = ui->checkBox_5->checkState();
item.Script_t << ui->textEdit->toPlainText();
// I've tried with replace but same error appears.
list->removeAt(editIndex);
list->insert(editIndex, item);
isEdit = false;
}
}
// Add or Edit existing conversation
void ConversationWindow::on_pushButton_2_clicked()
{
ConversationItem item;
if (!isEdit)
{
item.Key1_t = ui->lineEdit->text();
item.Key2_t = ui->lineEdit_2->text();
item.Key3_t = ui->lineEdit_3->text();
item.getState = ui->checkBox->checkState();
item.setState = ui->checkBox_2->checkState();
item.getStateValue = ui->spinBox->value();
item.setStateValue = ui->spinBox_2->value();
item.JustAnswer = ui->checkBox_3->checkState();
item.Answer_t = ui->lineEdit_4->text();
item.isScript = ui->checkBox_5->checkState();
item.Script_t << ui->textEdit->toPlainText();
list->append(item);
close();
window->DrawTalk();
} else {
item.Key1_t = ui->lineEdit->text();
item.Key2_t = ui->lineEdit_2->text();
item.Key3_t = ui->lineEdit_3->text();
item.getState = ui->checkBox->checkState();
item.setState = ui->checkBox_2->checkState();
item.getStateValue = ui->spinBox->value();
item.setStateValue = ui->spinBox_2->value();
item.JustAnswer = ui->checkBox_3->checkState();
item.Answer_t = ui->lineEdit_4->text();
item.isScript = ui->checkBox_5->checkState();
item.Script_t << ui->textEdit->toPlainText();
// I've tried with replace but same error appears.
list->removeAt(editIndex);
list->insert(editIndex, item);
isEdit = false;
}
}
To copy to clipboard, switch view to plain text mode
I'm parsing the item index correctly checked with debug.
Please help me
)
Bookmarks