今天使用到了QT中QTableWidget的清空和删除功能,特地整理出。
参考https://blog.csdn.net/qq_16093323/article/details/79226349
如下:
1、void QTableWidget::clear() [slot]
Removes all items in the view. This will also remove all selections and headers.
//清空表格中所有内容(包含表头)。
2、void QTableWidget::clearContents() [slot]
Removes all items not in the headers from the view. This will also remove all selections. The table dimensions stay the same.//清空表格中的内容(不包含表头)。
3、void QTableWidget::removeCellWidget(int row, int column)
//删除表格中的某行中的某列内容。
Removes the widget set on the cell indicated by row and column.
4、void QTableWidget::removeColumn(int column) [slot]
//删除表格中的某列内容。
Removes the column column and all its items from the table.
5、void QTableWidget::removeRow(int row) [slot]
//删除表格中的某行内容。
Removes the row row and all its items from the table
6、QTableWidgetItem * QTableWidget::takeItem(int row, int column)
//删除表格中的某行和某列
Removes the item at row and column from the table without deleting it.
7、QTableWidgetItem * QTableWidget::takeHorizontalHeaderItem(int column)
//删除表格中的水平标题头
Removes the horizontal header item at column from the header without deleting it.
8、QTableWidgetItem * QTableWidget::takeVerticalHeaderItem(int row)
//删除表格中的垂直标题头
Removes the vertical header item at row from the header without deleting it.