我正在使用QTreeView和兩個基於QSortFilterProxyModel的過濾器。我需要獲取QTreeView中當前顯示的項目列表,所以我選擇了索引(通過 - > selectionModel() - > selectedIndexes()),將它們傳遞到簡單的遞歸函數,但總是得到SIGSEGV。在調試中,我發現調用棧結束的地方 - 它在QVector :: fill中的某處。QTreeView的兩個嵌套代理模型和段錯誤
也許我做錯了什麼?如果我通過mapToSource()
通過索引,我得到的所有項目,不只是顯示的。
迭代函數很簡單:
void CollectionTreeWidget::iterator(const QModelIndex & index, QModelIndexList & items)
{
int count = p->dateFilterProxy->rowCount(index);
for (int i=0; i<count; i++) {
QModelIndex t = index.child(i, 0);
iterator(t, items);
}
}
這裏dateFilterProxy
是所使用的QTreeView則模型的模型。代碼崩潰rowCount
調用。
有沒有任何方式'p'或'dateFilterProxy'可能會變成陳舊? – cmannett85 2012-08-14 12:40:01
不,它們在整個應用程序運行時都是一樣的。 – 2012-08-14 16:04:43