I want to open Directory and file using the same function. Is it possible to do the same in QT. I used
QString directory = QFileDialog::getExistingDirectory(this, tr("Open Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
Here i can open only directory. How to open both file and directory using single function
Well, I don't think QFileDialog can do this job... Maybe you can use a QDirModel. That should do the trick... On clicking your "Browse"-button or something like that, you open a widget with a QTreeView using a QDirModel, there you can take the selected item and its path as your file/directory. For further information, see the documentation and the Dir View example in Qt Assistant.
EDIT: It is recommended to use QFileSystemModel instead of QDirModel. Thanks to Patrice for the advice.
You have to do it by yourself by: