I am making a file browser using QTreeView and QFileSystemModel. It must be selected and scroll the tree to a selected item automatically. But it doesn't work scroll automatically without getting keyboard.
QString strFile = "/usr/bin/qmake";
QFileInfo fi(strFile);
QString dirFile = fi.dir().absolutePath();
QFileSystemModel model;
model.setRootPath("/");
model.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
QTreeView view;
view.setModel(&model);
tree.setCurrentIndex(model.index(strFile));
tree.scrollTo(model.index(strFile));
view.show();
When executing above code, scroll is top but file is selected.
What's the problem not to scroll to selected item?