简体   繁体   English

QFileDialog慢速网络

[英]QFileDialog Slow Network

I am using QFileDialog both getOpenFileName and getSaveFileName . 我正在使用QFileDialog getOpenFileNamegetSaveFileName I have a file out on the network (slow connection), that I load with getOpenFileName . 我在网络上有一个文件(连接速度慢),我用getOpenFileName加载。 Then if I try to create a new QFileDialog , it takes forever to load. 然后,如果我尝试创建一个新的QFileDialog ,它需要永远加载。

I looked at the process with Process Monitor and I can see it slowly crawling through every file in the network location where I last opened the file. 我用Process Monitor查看了这个过程,我可以看到它慢慢地遍历我上次打开文件的网络位置中的每个文件。 It remains slow until I restart the computer. 在我重新启动计算机之前,它仍然很慢。 What can I do to speed this up? 我该怎么做才能加快速度呢?

Here is some code: 这是一些代码:

Open File Dialog 打开文件对话框

QString filename;
QFileDialog fd(this);
filename = fd.getOpenFileName(this,tr("Open CSV File"), ".",tr("CSV Files (*.csv)"));

Save File Dialog 保存文件对话框

QString filename;
QFileDialog fd(this);
filename = fd.getSaveFileName(this,tr("Save CSV File"), ".",tr("CSV Files (*.csv)"));

Thank you. 谢谢。

Unfortunately, there's nothing else that you can do about that if you use the native dialog like you do. 不幸的是,如果您像使用本机对话框一样,那么就无法做到这一点。 The getOpenFileName opens the native file dialog, and it's this native platform code that enumerates the files in the target directory. getOpenFileName打开本机文件对话框,这是本机平台代码,它枚举目标目录中的文件。

If you don't need the native dialog, you can do all sorts of things to work around the blocking/synchronous directory iteration interface to fundamentally asynchronous I/O resources. 如果您不需要本机对话框,则可以执行各种操作来解决阻塞/同步目录迭代接口到基本异步的I / O资源。

Try the option QFileDialog::DontUseNativeDialog . 尝试选择QFileDialog::DontUseNativeDialog This should forbid to open a native dialog. 这应该禁止打开本机对话框。

I am using non-native dialogs (by deriving from QFileDialog) for years to get rid of the problems you described. 我使用非原生对话框(通过从QFileDialog派生)多年来摆脱你描述的问题。

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

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