print QUrl.fromLocalFile(x).isValid()<br>d.openUrl(QUrl.fromLocalFile(x))<br><br>It's valid, but still doesn't work<br><br><div class="gmail_quote">W dniu 26 stycznia 2009 09:55 użytkownik Sergio Jovani <span dir="ltr"><<a href="mailto:lesergi@gmail.com">lesergi@gmail.com</a>></span> napisał:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
You have to specify fromLocalFile() in QUrl():<br>
<br>
DesktopServices().openUrl(QUrl.fromLocalFile("/home/piotr/test2/lol<br>
bar/photo_4900_8ea80c_huge.jpg"))<br>
<br>
Bye!<br>
<br>
2009/1/26 piotr maliński <<a href="mailto:riklaunim@gmail.com">riklaunim@gmail.com</a>>:<br>
<div><div></div><div class="Wj3C7c">><br>
><br>
> 2009/1/26 David Boddie <<a href="mailto:david@boddie.org.uk">david@boddie.org.uk</a>><br>
>><br>
>> On Sun Jan 25 22:17:46 GMT 2009, piotr malinski wrote:<br>
>><br>
>> > Here is an example script:<br>
>> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
>> > from PyQt4.QtCore import *<br>
>> > from PyQt4.QtGui import *<br>
>> ><br>
>> > d = QDesktopServices()<br>
>> ><br>
>> > x = '/home/piotr/test2/lol bar/photo_4900_8ea80c_huge.jpg'<br>
>> > print QUrl(x).isValid()<br>
>> > d.openUrl(QUrl(x))<br>
>> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
>> > The problem is it won't work if there is a space in the path - "lol<br>
>> > bar", for spaceless paths it works (also for example on windows it<br>
>> > needs paths with slashes not backslashes...). How can I make the path<br>
>> > valid for QDesktopServices? (the QUrl itself is valid)<br>
>><br>
>> Perhaps try encoding the URL first:<br>
>><br>
>><br>
>> <a href="http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qurl.html#toEncoded" target="_blank">http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qurl.html#toEncoded</a><br>
>><br>
>> This may be related to a bug that was apparently fixed in Qt 4.4.0:<br>
>><br>
>><br>
>> <a href="http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=194046" target="_blank">http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=194046</a><br>
>><br>
>> You don't say which version of Qt you are using. If it's later than Qt<br>
>> 4.4.0,<br>
>> it would be good if you could report this as a bug using the Task Tracker.<br>
>><br>
>> David<br>
>> _______________________________________________<br>
>> PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
>> <a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
><br>
><br>
> PyQt 4.4.4-r1, Qt 4.4.2, and using:<br>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
> from PyQt4.QtCore import *<br>
> from PyQt4.QtGui import *<br>
><br>
> d = QDesktopServices()<br>
><br>
> x = '/home/piotr/test2/lol bar/photo_4900_8ea80c_huge.jpg'<br>
> x = unicode(QUrl(x).toEncoded()<br>
> print x<br>
> print QUrl(x).isValid()<br>
> d.openUrl(QUrl(x))<br>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
> Doesn't help. So is it a Qt bug?<br>
><br>
> _______________________________________________<br>
> PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
> <a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
><br>
</div></div></blockquote></div><br>