PyQt5 QFileDialog迟滞问题临时解决
作者:互联网
PyQt5 QFileDialog.getExistingDirectory
date
:2021-06-11
问题说明
获取图像所在文件夹,然后返回路径将其更新到textBrowser
中。测试发现win10下会选择完路径后很久才返回文件夹地址,但该现象出现在我更新系统后,不知原因。
img_dir_path = QFileDialog.getExistingDirectory(self,
caption='Select Image Directory',
directory=os.getcwd())
self.image_path_line.setText(str(img_dir_path))
解决办法
The QFileDialog constructor creates a Qt dialog, whereas the static functions (like getSaveFileName) will create a native one (unless the DontUseNativeDialog option is set to True).
无法保证系统的NativeDialog比qt自带的快,但是测试发现qt自带的速度更快。所以有解决办法:
img_dir_path = QFileDialog.getExistingDirectory(self,
caption='Select Image Directory',
directory=os.getcwd(),
options=QFileDialog.DontUseNativeDialog)
self.image_path_line.setText(str(img_dir_path))
或者直接输入文件夹路径。
标签:getExistingDirectory,迟滞,img,self,PyQt5,QFileDialog,path,dir 来源: https://blog.csdn.net/AnimateX/article/details/117827959