[Qt-interest] Slow response when opening URL using QDesktopServices

Dickymoe dickymoe at gmail.com
Wed Aug 5 11:18:29 CEST 2009


Hello, i'm trying the same thing : open a folder in windows explorer.

I do :

QFileInfo file_info(filePath());

QDesktopServices::openUrl(QUrl::fromLocalFile(file_info.absolutePath()));

The first time this slot is call it's very long and after it's is
instantaly.

Thanks for your explanation.


On Mon, May 18, 2009 at 11:00, Jaco Naude <naude.jaco at gmail.com> wrote:

> Hi
>
> I am experiencing some strange behavior when opening a older on windows
> using QDesktopServices. My code is below. It basically gets a file name,
> removes the file name from the path and then tries to open the folder.
>
> void MainWindow::openFolder(const QString& folder_to_open) {
>
>     btnClearLogClick();
>
>     QDir folder_dir;
>
>     folder_dir.setPath(folder_dir.fromNativeSeparators(folder_to_open));
>
>     QStringList folder_tokens = folder_dir.absolutePath().split("/");
>
>     if (folder_tokens.size() == 0) {
>
>        logMessage("",MainWindow::Info);
>
>        logMessage(QString("An error occurred when analyzing the file's
> path."),MainWindow::Error);
>
>       return;
>
>     }
>
>     folder_tokens.pop_back();
>
>     QString folder_analyzed = folder_tokens.join("/");
>
>     logMessage(QString("Opening folder:
> %1").arg(folder_analyzed),MainWindow::Info);
>
>     QDesktopServices explorer_service;
>
>
> explorer_service.openUrl(QUrl(QString("file:%1").arg(folder_analyzed)));
>
> }
>
>
> When I run this function, the GUI freezes for about 10 seconds and then
> responds by opening the correct folder. When I debug it and step through the
> function it works perfectly and I don't notice any delays. It only happens
> the first time the application is opened, thus calling this function for a
> second and third time etc. does not cause the delay.
>
>
> Any ideas of what may cause thing?
>
>
> Thanks,
>
> Jaco
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090805/76d3a959/attachment.html 


More information about the Qt-interest-old mailing list