PyQt5 - 如何将Qfiledialog带到前面?

时间:2018-03-06 21:47:55

标签: python pyqt5 qfiledialog

我的代码使用PyQt打开文件夹选择对话框。选择文件夹后,它将被最小化。我想让对话框弹出任何其他窗口。我还没有找到解决方案。有什么建议吗?

from sys import executable, argv
from subprocess import check_output
from PyQt5.QtWidgets import QFileDialog, QApplication

def gui_fname(directory=''):
    file = check_output([executable, __file__, directory])
    return file.strip()

if __name__ == "__main__":
    directory = argv[1]
    app = QApplication([directory])
    folderpath = QFileDialog.getExistingDirectory(None, "Select folder")

1 个答案:

答案 0 :(得分:-1)

我认为你的问题来自"无"在以下功能中。 ORA-00933

无法设置对话框模态,因为它没有父级。通常,我们folderpath = QFileDialog.getExistingDirectory(None, "Select folder")代替None

编辑:cource应用程序不是从QWidget继承的。对不起。

请改用它。我测试了它的工作原理:

self