[PyQt] QDesktopServices openUrl doesn't work if URL-Path has
spaces etc.
David Boddie
david at boddie.org.uk
Mon Jan 26 00:44:58 GMT 2009
On Sun Jan 25 22:17:46 GMT 2009, piotr malinski wrote:
> Here is an example script:
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
>
> d = QDesktopServices()
>
> x = '/home/piotr/test2/lol bar/photo_4900_8ea80c_huge.jpg'
> print QUrl(x).isValid()
> d.openUrl(QUrl(x))
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> The problem is it won't work if there is a space in the path - "lol
> bar", for spaceless paths it works (also for example on windows it
> needs paths with slashes not backslashes...). How can I make the path
> valid for QDesktopServices? (the QUrl itself is valid)
Perhaps try encoding the URL first:
http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qurl.html#toEncoded
This may be related to a bug that was apparently fixed in Qt 4.4.0:
http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=194046
You don't say which version of Qt you are using. If it's later than Qt 4.4.0,
it would be good if you could report this as a bug using the Task Tracker.
David
More information about the PyQt
mailing list