[Qgis-developer] [Qgis-user] Reading Qsettings outside QGis

PIERRE Sylvain sylvain.pierre at cg67.fr
Fri Oct 12 00:46:03 PDT 2012


Thanks for interest!

You  are right. With no args QSettings outside Qgis return nothing. After consultinq Qt doc and with your help, this code is working:

QSettings( QSettings.NativeFormat, QSettings.UserScope, 'QuantumGIS', 'QGis')

Diving into Python, Qt and Pyqgis since few months, I have new questions each day, and each day, I find answers...

Great job made by all developpment teams and plugins developpers , where I can find lots of code.

-----Message d'origine-----
De : Etienne Tourigny [mailto:etourigny.dev at gmail.com] 
Envoyé : jeudi 11 octobre 2012 16:13
À : PIERRE Sylvain
Cc : qgis-user at lists.osgeo.org
Objet : Re: [Qgis-user] Reading Qsettings outside QGis

Hi Pierre,

yes this is the right approach.  However, you must make sure that the proper organisation (QuantumGIS) and application (QGIS) are set.  Your problem is probably because the QSettings is initialized with some default values.

This is done automatically when using plugins in the qgis app, but not if your are creating an external app.

Although it should happen when calling QgsApplication.initQgis() - you might want to file a bug report for that.

BTW - you might get more feedback if posting to the qgis-devel mailing list.

Etienne

On Thu, Oct 11, 2012 at 6:34 AM, PIERRE Sylvain <sylvain.pierre at cg67.fr> wrote:
> I'm developping a standalone application (Python, Qt, Qgis) and I 
> would like to read some settings that I currently use in my Qgis 
> projects : PostGis and Spatialite connections.
>
> I suppose I can get this values with QSettings, but I'm not sure.
>
> Is it the right way to do this ?
>
> I'm testing with the code below, with no result :
>
>         settings = QSettings()
>
>         settings.beginGroup("/PostgreSQL/connections")
>
>         keys = settings.childGroups()
>
>
>
>         for name in keys:
>
>             QMessageBox.warning(self,"Information",str(name))
>
>
>
>
>
> Any idea ?
>
>
>
> Thanks
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>


More information about the Qgis-developer mailing list