[SOLVED] QTreeview Double Clicked "The program unexpectedly finished"
-
Do you mean an example of calling
mapToSource
? -
wrote on 1 Feb 2016, 23:16 last edited by
Codes above
-
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
-
wrote on 3 Feb 2016, 10:51 last edited by
@SGaist I wrote this code and again I get error("the has unexpectedly finished") ```
void MainWindow::on_treeView_doubleClicked(const QModelIndex &index)
{if(index.isValid())
{
filter->mapToSource(model->index(dir));
qDebug()<<model->filePath(index);
}
} -
@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); -
wrote on 3 Feb 2016, 11:01 last edited by
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) -
wrote on 3 Feb 2016, 11:06 last edited by
Thanks everybody
23/23