An application I've converted from PyQt to PySide mostly works, but I've run into some trouble with QSettings()
Most of my development is on Ubuntu and the available version was lagging so I installed the PPA and got PySide 1.0.5. Contrary to the documentation, pulling in values does *not* restore the type. I have noticed that 1.0.4 on OSX and 1.0.5 on Windows appear to work correctly. A simple test case is as follows and illustrates the problem. First, yes, the fact that a str() object comes back as unicode() is expected. And I suppose that a tuple being converted to a list is no surprise. However, on linux running the script a second time loads the stored values rather than merely passing the values though PySide Qt functions. And this time bool, int and float are all converted into unicode strings. And the single item list is no longer a list, but a unicode string as well. And if the code is naive enough to trust PySide will return it as a list then the string is faithfully treated as a list -- one character at a time. On windows a second run loses the bool and float types to unicode, but the int and list types are preserved. On OS X, the only platform running 1.0.4, all types are loaded as expected: strings become unicode strings and tuples become lists. But bool, int, float and list types are all preserved. This looks to me like a bug. Perhaps it was introduced in 1.0.5, but even then the behavior differs between linux and windows. Or is this expected and I'm misunderstanding the documentation when it says that, unlike PyQt, there is no need to specify the variable type when restoring values from QSettings? Tim Doty ---- import PySide from PySide.QtCore import * thisApp = 'test' thisCompany = 'test' settings = QSettings(thisCompany, thisApp) someBool = settings.value('SomeBool', True) someInt = settings.value('SomeInt', 5) someFloat = settings.value('SomeFloat', 1.3) someStr = settings.value('SomeStr', 'string') someUni = settings.value('SomeUni', 'unicode') someTuple = settings.value('SomeTuple', ('one', 'two')) someList = settings.value('SomeList', ['three']) someDict = settings.value('SomeDict', {'key': 'value'}) if not isinstance(someBool, bool): print "someBool %s is not a bool" % someBool if not isinstance(someInt, int): print "someInt %s is not an integer" % someInt if not isinstance(someFloat, float): print "someFloat %s is not a float" % someFloat if not isinstance(someStr, str): print "someStr %s is not a string" % someStr if not isinstance(someUni, unicode): print "someUni %s is not unicode" % someUni if not isinstance(someTuple, tuple): print "someTuple %s is not a tuple" % someTuple if not isinstance(someList, list): print "someList %s is not a list" % someList if not isinstance(someDict, dict): print "someDict %s is not a dictionary" % someDict settings.setValue('SomeBool', someBool) settings.setValue('SomeInt', someInt) settings.setValue('SomeFloat', someFloat) settings.setValue('SomeStr', someStr) settings.setValue('SomeUni', someUni) settings.setValue('SomeTuple', someTuple) settings.setValue('SomeList', someList) settings.setValue('SomeDict', someDict) _______________________________________________ PySide mailing list PySide@lists.pyside.org http://lists.pyside.org/listinfo/pyside