[Qgis-developer] How set up last used directory
Richard Duivenvoorde
rdmailings at duif.net
Fri Nov 27 10:17:37 EST 2009
Giuseppe Sucameli wrote:
> I want to set up the last used directory for reading and saving, but I've
> looked in qgis code, there is no a standard setting for all plugins.
> So, i can use a plugin scope setting, but it's most useful discuss it to find
> the better solution.
Hi Giuseppe,
this is for python plugins yes?
if so, I had a similar question during the hackfest in Vienna for the
mapserverexport plugin. We wanted to remember last path for map-file,
size etc etc during sessions.
The answer then was: do it using QSettings:
http://doc.trolltech.com/4.5/qsettings.html#details
There are different ways for using it, but different plugins use it
already (I do grep -ir qsettings * now in my .qgis dir):
Plugin_installer
postgis_manager
We use it in the mapserverexport plugin like this:
see:
https://svn.osgeo.org/qgis/trunk/qgis/python/plugins/mapserver_export/mapserverexport.py
# ok succesfull: write some setting for a next session
settings = QSettings()
# mapfile name
settings.setValue("/MapserverExport/mapfileName",QVariant(self.dlg.ui.txtMapFilePath.text()))
and to read from it:
settings = QSettings()
rememberedval = settings.value("/MapserverExport/mapfileName",
QVariant("")).toString ()
As said, there are other way to use it to see
http://doc.trolltech.com/4.5/qsettings.html#details
Good Luck,
Richard Duivenvoorde
More information about the Qgis-developer
mailing list