[PyQt] QSettings error on Windows

Scott Frankel frankel at circlesfx.com
Sat Nov 14 18:35:28 GMT 2009


Hi,

I've put together a simple test app that demonstrates the problem I'm  
having with QSettings.value() INT arguments on Windows.

An invalid argument type error causes the app to crash on startup.   
Line 37 of the attached file is the culprit.  The line works without  
issue on OSX.  Do I need to wrap the integer setting value in a string  
to work around the invalid type error?  What's common practice for  
wrestling with integer Windows preference settings?

Thanks!
Scott


-------------- next part --------------
A non-text attachment was scrubbed...
Name: settingsTest.py
Type: text/x-python-script
Size: 1124 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20091114/05e8e22b/settingsTest.bin
-------------- next part --------------






On Nov 10, 2009, at 1:12 AM, Scott Frankel wrote:

>
> Hi,
>
> I'm getting a fatal error from the following QSettings line on  
> Windows.  But on Mac OSX, the same code runs without error.  The exe  
> log file says that argument 2 of settings.value() has an invalid  
> type.  That'd be my int.
>
> The first line of the method reads a string value.  That appears to  
> function properly on both platforms.
>
> Any suggestions?
>
> Thanks!
> Scott
>
>
> def readSettings(self):
>
>    self.dbHost = self.settings.value("Application/dbHost",  
> QtCore.QVariant(QtCore.QString("localhost"))).toString()    # this  
> works on both platforms
>
>    self.dbPort = self.settings.value("Application/dbPort",  
> 5432).toInt()[0]    # this fails on windows, but works on osx
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>










More information about the PyQt mailing list