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

PIERRE Sylvain sylvain.pierre at cg67.fr
Fri Oct 12 00:53:57 PDT 2012


Unfortunatly, it's not working. I forgot to comment old line wich was:

        settings = QSettings("HKEY_USERS\\S-1-5-21-135220595-821698489-1543119021-16853\\Software\\QuantumGIS\\QGIS",QSettings.NativeFormat)
and is working, but it's not a permanent solution.
The last one I mentioned is not working:
        settings = QSettings( QSettings.NativeFormat, QSettings.UserScope, 'QuantumGIS', 'QGis')
I use InitQGis in my app, but  QSettings() return nothing, so maybe here's a bug...


-----Message d'origine-----
De : qgis-user-bounces at lists.osgeo.org [mailto:qgis-user-bounces at lists.osgeo.org] De la part de PIERRE Sylvain
Envoyé : vendredi 12 octobre 2012 09:46
À : Etienne Tourigny
Cc : qgis-user at lists.osgeo.org; qgis-developer at lists.osgeo.org
Objet : Re: [Qgis-user] Reading Qsettings outside QGis

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
>
_______________________________________________
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