您的位置:首页 > 编程语言 > Qt开发

清空Qtablewiget 表格的内容

2017-04-11 15:31 246 查看
清空Qtablewiget 表格的内容:

void QTableWidget::clear () [slot]//清空掉表格内所有内容,包括标题头

Removes all items in the view. This will also remove all selections. The table dimensions stay the same.

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.

void QTableWidget::removeColumn ( int column ) [slot]//这个是删除一列,而不是清空表格

Removes the column column and all its items from the table.

void QTableWidget::removeRow ( int row ) [slot]//这个是删除一行,不是清空一行

Removes the row row and all its items from the table.


清除表格内容并释放内存,重新设置表格的行数num个数:

tableWidget->setRowCount(0);
tableWidget->clearContents();//释放内存
tableWidget->setRowCount(num);


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: