在 QT C++ 的 QTableWidget 中删除行的最快方法

发布于 2025-01-16 12:32:59 字数 791 浏览 3 评论 0原文

我想删除 QTableWidget 中某个范围之间的行。 这里唯一的问题是逐行删除......需要很长时间。

有没有办法通过在范围之间删除来加快速度?我想删除从 toRowfromRow 的行,其中 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文