Qtreeview : To get File name and path from Tree View
Hi ,
I am using the below code to show a particular path in tree view. Now when i click a file or select or focused file , i need to get the file path location and file info. How do i get it? Help me
Code:
tree.setModel(&model);
// Demonstrating look and feel features
tree.setAnimated(true);
tree.setIndentation(20);
tree.setSortingEnabled(true);
tree.setAllColumnsShowFocus(false);
tree.setRootIndex(model.index(directory));
tree.
setWindowTitle(QObject::tr("Dir View"));
tree.resize(320, 240);
tree.show();
tree.hideColumn(1);
tree.hideColumn(2);
tree.hideColumn(3);
return app.exec();
Re: Qtreeview : To get File name and path from Tree View
See QDirModel::fileInfo() or QDirModel::filePath() in conjunction with the current selected index or any other index. E.g. QAbstractItemView::activated().