PDA

View Full Version : QFIleDilaog Slow



afro_cv
24th August 2011, 19:13
Why QFileDialog is to slow?

stampede
24th August 2011, 19:34
QFileDialog is ok. Maybe you need more ram and faster cpu.

afro_cv
24th August 2011, 20:26
is ok? i have 2 computer, one with xp other with win 7.
The PC with windows 7 have 4 gigabytes, and only qtcreator is open.

And OpenFileDialog of another programs like firefox, word, chrome...is moreee faster.

stampede
24th August 2011, 21:02
Yeah, its quite ok for me. For example, right now I'm using windows 7, Qt Creator is taking 180 mb of my 2 Gb ram. I'm using Opera, winamp, Qt Assistant, Qt Designer and gdb opened with debug version of my app (which is taking ~400 mb). I still have ~600 mb ram available. CPU is not very fast (Pentium Dual-Core 2.1 GHz). QFileDialog::getOpenFileName or other methods runs very smooth.
Are you using static methods, or manually creating the dialog ?
And testing release or debug version ?

afro_cv
24th August 2011, 21:47
This is my code:



QList<QUrl> urls;
urls << QUrl::fromLocalFile(QDesktopServices::storageLocat ion(QDesktopServices::DesktopLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocat ion(QDesktopServices::HomeLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocat ion(QDesktopServices::DocumentsLocation));

QFileDialog dialog;
dialog.setSidebarUrls(urls);
dialog.getOpenFileName( this, tr("Adicionar Imagem"), QDir::currentPath(), tr("PNG files (*.png)"), 0, QFileDialog::DontUseNativeDialog );




I think is debug version. Because all my thing is in DEBUG FOLDER.

stampede
24th August 2011, 22:25
Ok, so maybe test the release version if you want to measure speed, debug version is usually slower.

NullPointer
24th August 2011, 23:37
Man,

I think your code is not much efficient....
QFileDialog::getOpenFileName is a static member, so I'm in doubt if this will work properly...
Try to find out another non-static member to pop the dialog and get the file name...

Hth.

gkarthick5
26th August 2011, 06:48
Why do you want to use
QFileDialog::DontUseNativeDialog?

Lesiok
26th August 2011, 07:19
Problem is with QFileDialog::DontUseNativeDialog. QFileDialog must read ALL files attributes and this is time consuming. Using native dialog is faster because OS caches this info.

grantbj74
7th March 2012, 04:44
I also find QFileDialog very slow.

If I select DontUseNativeDialog the dialog take ages to appear.

If I use the native dialog, it appears quickly, but when you click on it, it takes ages to react.

My PC is Windows XP with 4GB Ram.

My first thoughts was its Windows problem.

Windows Explorer can be a bit slow at times on this PC too.

d_stranz
7th March 2012, 04:55
I also have this problem, and I think in my case it is probably unrelated to Qt or QFileDialog, but the problem is especially noticeable with QFileDialog.

I have a fast PC, but I also have about 6 external USB drives. What I think causes the slowness is that before the dialog can be populated, it has to spin up and sync all of the external drives that have powered down due to their power-saving energy efficiency features. I still use File Manager (I *hate* :mad: Explorer), and when I switch windows to one of the USB drives, it can take 30 seconds or more before the folder expands.

So, if you have a similar configuration with big external USB or eSATA drives, this might be the real cause of the slowness.

grantbj74
7th March 2012, 05:13
I don't usually have USB devices going.

But I do have a heap of network drives, maybe they slow it down.

Might have to make my own file dialog box that isn't so smart.

I just used an old QT application that has QFileDialog in it. It doesn't seem slow at all. So maybe mine is a code issue.

d_stranz
7th March 2012, 05:26
I just used an old QT application that has QFileDialog in it. It doesn't seem slow at all. So maybe mine is a code issue.

If the old Qt app is using older Qt DLLs, it might also be a behavior difference. There was a pretty major change in the way Qt handles access to the file system in Qt 4.4 where the QFileSystemModel was introduced to replace QDirModel, and in 4.2, where QFileSystemWatcher was introduced. My guess is that QFileDialog was also reimplemented to use the new QFileSystemModel. So the difference you see might be a pre-4.4 vs. post-4.4 QFileDialog implementation.

grantbj74
7th March 2012, 06:51
I just recompiled the old application. It is slow now too.

I don't think it's a QT issue though. As i'm fairly sure we have never upgraded QT. Think im using QT 4.6.3.

I think I may have the solution. My old debug application is slow and 45mb in size. Where as the same version old released is fast and 15mb in size.

So maybe try compiling a released version.

Unfortunately I can't do a released version of my new app until someone adds QWT to the autobuilder machine. I'll let you know if this ever happens ;)