Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8204445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:54:21+00:00 2026-06-07T07:54:21+00:00

i am creating a table and uinserting the row in it like this.only one

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:54:22+00:00Added an answer on June 7, 2026 at 7:54 am

    I dont know if this will fix your problem, because you have a lot of ambiguous member references in this example, but are you sure that you are clearing that QList m_list each time afterwards? Possibly you are just accumulating more items each time.

    Try getting rid of the QList+addRow and just do:

    m_model->setItem(0,0,item1)
    m_model->setItem(0,1,item2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating table like this: CREATE TABLE foobar (id uniqueidentifier, foo text, bar
I'm creating a table inside a repeater programmatically. My problem is that the cells
I am creating a table where it has a foreign key so that it
I am creating a table for an application that handles scheduling and deals with
I am creating a program that is going to insert data into a table
When inserting a new row in a table T, I would like to check
I'm creating a log table which logs actions that affect the database, and I
I have simple table in Sybase -- Creating table 'SimpleText' CREATE TABLE [dbo].[SimpleText] (
Hi Following is the syntax for creating table in mysql. I want to create
hi all i am declaring id and class when creating table dynamically as below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.