“浏览文件夹”Windows 对话框非常不方便,因为:
有没有一种方法可以使用“打开文件”对话框(这是更好的)选择一个文件夹?旗帜或者选项什么的?
上下文: 用 Python 和 Qt 编写的 口径电子图书馆管理器。
它目前显示在左边。我希望它显示在右边
甚至更好,如打开文件对话框:
You can set the file mode in QFileDialog to QFileDialog::Directory
QFileDialog
QFileDialog::Directory
see http://qt-project.org/doc/qt-5.0/qtwidgets/qfiledialog.html#FileMode-enum
Or You can use QFileDialog::setOption with value QFileDialog::ShowDirsOnly
QFileDialog::setOption
QFileDialog::ShowDirsOnly
You can try this one:
QString QFileDialog::getExistingDirectory ( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), Options options = ShowDirsOnly ) [static]
This one is used to choose a directory, and will popup a dialog like you show at last.
Demo:
QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);