PDA

View Full Version : why QDesktopServices::openUrl() open a file slowly for the first time



myhot21
31st July 2009, 05:56
I use QDesktopServices::openUrl() to open a file(.doc,xls,pdf), it takes 30-60 seconds to open file(.doc) for the first time, after that, it only takes 1-5 seconds to open anther file(.doc).it is same to file(xls, pdf).
Why it takes long time to open file for the first time?

yogeshgokul
31st July 2009, 06:12
It looks for best matched application to open the particular URL. I think this searches in file associations. And this first time trick is with all things we do on a machine. Everything we opens is slower for first time than opening same ting afterward.

myhot21
31st July 2009, 09:45
It looks for best matched application to open the particular URL. I think this searches in file associations. And this first time trick is with all things we do on a machine. Everything we opens is slower for first time than opening same ting afterward.

How can i make QDesktopServices::openUrl() open file speed up for first time?

yogeshgokul
31st July 2009, 09:56
There is very less you can do. Dfragment ur HDD or just replace it with higher RPM one. ;);) Kidding..

Just try to use this:


QDesktopServices::openUrl(QUrl("file:///C:/Documents and Settings/All Users/Desktop", QUrl::StrictMode));

NOTICE QUrl::StrictMode
This should not make significant change but may be. Dont forget, that this will not check for validity of URL. Thats why it can speed up.

nightghost
3rd August 2009, 20:25
I think this is not a fault of Qt. If you open a doc the first time Word (the program) needs to be completely loaded into the memory. This takes a long time. If you open a second doc Word is already in memory (even if word was closed) and only the doc needs to be loaded.

I dont think, that using Strictmode for QUrl will have any significant speed improvements.