[SOLVED] QTreeview Double Clicked "The program unexpectedly finished"
-
Do you mean an example of calling
mapToSource
? -
In the code above, you are trying to use an index from your proxy on your file system model. That's the problem, you have to use mapToSource in order to get the right index.
-
In on_treeView_doubleClicked
-
-
@takoo said:
Hi
http://doc.qt.io/qt-5.5/qsortfilterproxymodel.html#mapToSource
it returns a new index. I assume you should use that index.
you still use "old" index filePath(index);QModelIndex mapped=filter->mapToSource(model->index(dir));
model->filePath(mapped); -
hi ```
I get error (QSortFilterProxyModel: index from wrong model passed to mapToSource)
void MainWindow::on_treeView_doubleClicked(const QModelIndex &index)
{if(index.isValid())
{
QModelIndex mapped=filter->mapToSource(model->index(dir));qDebug()<<model->filePath(mapped); }
}
-
oh
maybe its
mapToSource(index)