简体   繁体   English

QFileDialog在确定按钮激活时关闭

[英]QFileDialog close on OK button activation

I am using pyqt4 and windows. 我正在使用pyqt4和Windows。 I have an application where I select a directory using QFileDialog. 我有一个应用程序,可以在其中使用QFileDialog选择目录。 After the directory is selected, I want to close the file dialog when the user selects the OK button of the file dialog. 选择目录后,我想在用户选择文件对话框的“确定”按钮时关闭文件对话框。 The behavior desired should be the same as the behavior of the cancel button. 所需的行为应与取消按钮的行为相同。 How can I do this? 我怎样才能做到这一点?

Thanks 谢谢

使用QFileDialog.getExistingDirectory()静态方法。

 dir = QtGui.QFileDialog.getExistingDirectory(self);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM