[SOLVED]If I add an item to QTreeWidget it always gets inserted in first row
-
I want new items to be inserted after the last row instead of first row. Plz help!
@QTreeWidgetItem *item1=new QTreeWidgetItem(ui->treeWidget);
item1->setText(0,hostname);@ -
Yes, because YOU put the item into the first (index at 0)position.
Try something like this:
item1->setText(Your_QTreeWidget::topLevelItemCount(),hostname); -
@item1->setText(0,hostname);@
In this case the first parameter- 0 is not the row number, but column number.
-
This?:
@
Your_QTreeWidget::insertTopLevelItem ( Your_QTreeWidget::topLevelItemCount(), item1 )
@ -
It still inserts the item at top. How to add items at the bottom.
-
It worked after disabling sorting.