[PyQt] QSettings with QColor in PyQt

Hans-Peter Jansen hpj at urpla.net
Tue Apr 12 12:24:49 BST 2011


On Tuesday 12 April 2011, 11:23:33 goocreations wrote:
> I want to store and retrieve a QColor from QSettings. storing is no
> problem:
>
> self.settings.setValue("Color", myColor)
>
> But I can't figure out how to retrieve it again. In C++ you would
> just call .value<QColor>(), but this is not possible in Python.
>
> Any ideas?

Simply wrap the value with a matching c'tor:
    
    QtGui.QColor(value)

Using a reasonably current PyQt, you can provide a type argument:

    QSettings.value("Color", QtGui.QColor)

Pete


More information about the PyQt mailing list