How to delete whole table in qtablewidget?
I want to destroy the content of whole table including the horizontalheader, verticalheader,and all the items so I can create a fresh table, how can I do that I tried clear and remove ow but header were not removed by so, since I want to remove all table content is there any way to do so?
@vasu_gupta Hi, friend. Welcome.
About the content of table, you can use
QTableWidget::clearto clear. But the table header, you should
deletethem. you can use
takeHorizontalHeaderItem(int column)to take header item, and then to delete it.
You can use hide,setvisible(false) for header. To remove all the contents, use setrowcount(0).
QAbstractItemModel* const mdl = tablewidget->model(); mdl->removeRows(0,mdl->rowCount()); mdl->removeColumns(0,mdl->columnCount());
To remove all the contents, use setrowcount(0).
Will the model be cleared?
This post is deleted!