PDA

View Full Version : QStandardItem Error: Ignoring duplicate insertion problem



Daxos
16th June 2010, 20:15
Hi,
I have a problem. This is the code of my application:

QtCode:


QList<QStandardItem*> items1;
QList<QStandardItem*> items2;
name->setText("1");
rank->setText("2");
profile->setText("3");
items.append(name);
items.append(rank);
items.append(profile);
model->appendRow(items);
qDebug() <<"List: " << items.at(2)->text();
name->setText("4");
rank->setText("5");
profile->setText("6");
items2.append(name);
items2.append(rank);
items2.append(profile);
qDebug() <<"List: " << items2.at(2)->text();
model->appendRow(items2);


I use QStandardItemModel in my QTableView.

Whit this code i should be this table:
1 2 3
4 5 6.

But I have this outup and this error:



Output:

List: "3"
List: "6"
QStandardItem::insertRows: Ignoring duplicate insertion of item 0x38137d0
QStandardItem::insertRows: Ignoring duplicate insertion of item 0x38137c0
QStandardItem::insertRows: Ignoring duplicate insertion of item 0x38137b0


My final table is:

4 5 6
[blank] [blank] [blank]

How i can solve this problem?


Thanks, bye

wysota
16th June 2010, 20:19
You need to create a new set of items for the second row just like you did with the first row.