i am creating a table and uinserting the row in it like this.only one row is inserted in the table and that too conditional and if condition isnt satisfied than an error is shown. the problem is that when a row is inserted on satisfying condition then,the other row when inserted on again satisfying condition doesnt re write that row but uses the next two column of that row keepinf the previous two column empty.
Example
first result:
2 hello
second result:
3 hello
Code
void searchWindow::TextReturn()
{
int id = (text->text()).toInt();
map<int,QString>::iterator itt;
itt = appWindow::dataa.find(id);
if(itt != appWindow::dataa.end()) //returns 1 if we found something
{
m_mode1 = new QStandardItemModel(0,2,this);
m_mode1->setHorizontalHeaderItem(0, new QStandardItem(QString("ID")));
m_mode1->setHorizontalHeaderItem(1, new QStandardItem(QString("DATA")));
m_items << new QStandardItem((QString("%1").arg(id)));
m_items << new QStandardItem((*itt).second);
m_mode1->appendRow(m_items);
m_tablee->update();
text->setText("");
m_tablee->setModel(m_mode1);
}
else
{
m_mode1 = new QStandardItemModel(0,2,this);
m_mode1->setHorizontalHeaderItem(0, new QStandardItem(QString("SEQUENCE")));
m_mode1->setHorizontalHeaderItem(1, new QStandardItem(QString("MESSAGE")));
m_msgBox = new QMessageBox();
m_msgBox->setWindowTitle("Alert");
m_msgBox->setText("INVALID ID ENTERED");
m_msgBox->show();
text->setText("");
m_tablee->setModel(m_mode1);
}
}
thanks for any help in advance