[Qgis-developer] Displaying help files for a plugin
Chris Crook
ccrook at linz.govt.nz
Mon Feb 8 19:33:21 EST 2010
What happened with the Qt openUrl functio a file:// url was that nothing happened! There was a pause when it looked as if something should have happened - but then the application carried on and no browser window appeared. Presumably this is the reason for the workaround in the source code. The work-around does work - that is ShellExecute fires up the browser as expected. I'm not sure what Qt is trying to do. Anyway, I found QgsInterface function when I was looking through the source code for the Qt openUrl function - so your pointer was invaluable!
Thanks
Chris
-----Original Message-----
From: b.rowlingson at googlemail.com [mailto:b.rowlingson at googlemail.com] On Behalf Of Barry Rowlingson
Sent: Tuesday, 9 February 2010 7:55 a.m.
To: Chris Crook
Cc: qgis-developer at lists.osgeo.org
Subject: Re: [Qgis-developer] Displaying help files for a plugin
On Mon, Feb 8, 2010 at 5:54 PM, Chris Crook <ccrook at linz.govt.nz> wrote:
> Turns out QDesktopServices.openUrl doesn't quite work on Windows with
> a file:// type url - at least in the version of Qt we are using. But
> the good news is that it is already handled in Qgis. The QgsInterface
> class has an openURL methods (note captilisation) that does the job.
> It takes two parameters, a string (the url), and a boolean which if
> true causes it to look in the Qgis documentation folder. So the code
> I ended up with (based on Barry's) is
Ah, the Qgis devs worked round that problem in qgisapp.cpp:
#elif defined(WIN32)
if ( url.startsWith( "file://", Qt::CaseInsensitive ) )
ShellExecute( 0, 0, url.mid( 7 ).toLocal8Bit().constData(), 0, 0, SW_SHOWNORMAL );
else
QDesktopServices::openUrl( url );
#else
What does your Qt version do with file:// in Windows? The docs for Qt 4.5 say:
"If the URL is a reference to a local file (i.e., the URL scheme is
"file") then it will be opened with a suitable application instead of a Web browser."
so unless you have .html set to open with something else (an editor?) then it should work. ShellExecute just opens it with whatever application is registered as well, note that they lop the 'file://'
bit off first.
Barry
--
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman
______________________________________________________________________________________________________
This message contains information, which is confidential and may be subject to legal privilege.
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.
Thank you.
______________________________________________________________________________________________________
More information about the Qgis-developer
mailing list