打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
PyQt

If you omit the dir argument (or pass in an empty string), the dialog should remember the last directory:

    filename = QtGui.QFileDialog.getOpenFileName(                   parent, 'Open File', '', 'Images (*.png *.xpm *.jpg)')

The tr function is used for translating user-visible strings. You can omit it if you won't ever be providing translations for your application.

EDIT:

It seems that the start directory may not be automatically remembered on all platforms/desktops, depending on whether you use the native dialog or not. If Qt's built-in dialog is used, the start directory should always be automatically remebered on all platforms (even between invokations of the application). To try the non-native dialog, do:

    filename = QtGui.QFileDialog.getOpenFileName(                   parent, 'Open File', '', 'Images (*.png *.xpm *.jpg)',                   None, QtGui.QFileDialog.DontUseNativeDialog)

Alternatively, you can use the QFileDialog constructor, which will always create a non-native dialog:

    dialog = QtGui.QFileDialog(parent)    dialog.setWindowTitle('Open File')    dialog.setNameFilter('Images (*.png *.xpm *.jpg)')    dialog.setFileMode(QtGui.QFileDialog.ExistingFile)    if dialog.exec_() == QtGui.QDialog.Accepted:        filename = dialog.selectedFiles()[0]
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Qt中打开保存文件的文件过滤器怎么设置
PyQt4编程简介
QFileDialog的用法
如何使用ui文件
Qt中不规则窗体和部件的实现
Qt学习之路(15): Qt标准对话框之QFileDialog
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服