0

I am making one simple program of in which i have two arrays. I want to insert first array in the first column of the child of treeWidget and second array in the second column of the treeWidget. First array is inserted successfully. Now i want to insert second array in the same index of second column. Like this

object
   //First Column                          //Second Column
     A                                          1
     B                                          2
     C                                          3

Object is the parent. Coding:

QTreeWidget* item= new QTreeWidgetItem();
QList<QTreeWidgetItem*> items_first_Column;
QList<QTreeWidgetItem*> items_Second_Column;

item->setText(0,"Object");
item->addChildren(items_first_column);

Can anyone please tell me how i can insert second column in this.

Hamid
  • 137
  • 1
  • 11

1 Answers1

-1

You will have to restructure your code a little bit I think. The second column does not consist of a new bunch of QTreeWidgetItems. There is only on list of child items, but instead each item can contain text in several colums.

So you'll have to create a single list of items and put you data into these with QTreeWidgetItem::setText() for example, giving the column number as the first parameter.

You could iterate over both your lists and change the items of items_first_Column to contain the text of those from items_Second_Column in their second column. But if possible I would advise to restructure your surrounding code to take this into account beforehand.

Steffen
  • 2,888
  • 19
  • 19