[Qgis-developer] Displaying help files for a plugin

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Feb 8 13:55:24 EST 2010

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,
    QDesktopServices::openUrl( url );

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.


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

More information about the Qgis-developer mailing list