Solved Update data to QTreewidget every sec
-
-
What is the problem?
What help do you need?
Where does the data come from? -
@jsulm
I am getting the data from another class. i need to display this data. I am able display it the first time but its not autorefreshing so I put this timer and a slot updateData(). I need help in writing this function. -
What help do you need?
Most simple solution: in updateData() you recreate the complete tree (delete all items and then add new items based on current data). -
@jsulm
I have done that but the text added byitem1->setText(0,"data1");
is not getting deleted. I have used the following code to delete all the items.for(int i=0;i< ui->treeWidget->topLevelItemCount();++i){ qDeleteAll(ui->treeWidget->topLevelItem(i)->takeChildren()); }
-
hi
Cant
http://doc.qt.io/qt-5/qtreewidget.html#clear
be used ? -
@mrjj
Ya it works but the parent item gets closed on every update. -
@saitej
No matter how you remove the items, it cannot
keep open/close status since you remove the items. -
@mrjj
so is there a way to get back to the same status as before after the update ? -
@saitej
Hi, not as far as I know. not unless u save it yourself. -
@mrjj
ok !! Thanks :)