QTableWidget刪除選中行

原文:http://beself.top/2020/02/15/qtablewidget-delete-selectrows/
在使用QTableWidget時刪除選中行時稍微麻煩點,記錄一下

// 刪除選中行
void JInfoManger::deleteSelectRows()
{
    QList<QTableWidgetSelectionRange> sRangeList = TableAccount->selectedRanges();
    for(const auto &p : qAsConst(sRangeList)) {
        for (auto i = p.topRow() + p.rowCount() - 1; i > p.topRow() - 1; i--) {
            TableAccount->removeRow(i);
        }
    }
}
發佈了29 篇原創文章 · 獲贊 13 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章