在 QT C++ 的 QTableWidget 中删除行的最快方法
我想删除 QTableWidget
中某个范围之间的行。 这里唯一的问题是逐行删除......需要很长时间。
有没有办法通过在范围之间删除来加快速度?我想删除从 toRow
到 fromRow
的行,其中 toRow >来自行
/* Create progress bar */
QProgressDialog progress("Loading table...", "Abort loading", fromRow, toRow, this);
progress.setWindowModality(Qt::WindowModality::ApplicationModal);
/* Delete */
if(database->deleteRowsBetweenID(fromID, toID)){
/* Remove each row */
for(int i = toRow; i >= fromRow; i--){
ui->measurementTableWidget->removeRow(i);
/* Break the process */
if (progress.wasCanceled())
break;
else
progress.setValue(toRow - i);
}
/* Close the progress bar */
progress.setValue(toRow);
I want to delete rows in QTableWidget
between a range.
The only problem here is that deleting row by row...takes very long time.
Is there a way to make this faster by deleting between a range? I want to delete rows from toRow
to fromRow
, where toRow > fromRow
/* Create progress bar */
QProgressDialog progress("Loading table...", "Abort loading", fromRow, toRow, this);
progress.setWindowModality(Qt::WindowModality::ApplicationModal);
/* Delete */
if(database->deleteRowsBetweenID(fromID, toID)){
/* Remove each row */
for(int i = toRow; i >= fromRow; i--){
ui->measurementTableWidget->removeRow(i);
/* Break the process */
if (progress.wasCanceled())
break;
else
progress.setValue(toRow - i);
}
/* Close the progress bar */
progress.setValue(toRow);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论