From a4df604eb0061ccfcea861f5a0d836a0885ef9fd Mon Sep 17 00:00:00 2001 From: duplo Date: Thu, 8 Jan 2009 17:08:13 +0000 Subject: [PATCH] Add the Python type -> QVariant conversion function git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2143 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/qvariant_converter.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/wizard/qvariant_converter.py b/wizard/qvariant_converter.py index 256b4fc3..d1854bff 100644 --- a/wizard/qvariant_converter.py +++ b/wizard/qvariant_converter.py @@ -15,21 +15,42 @@ def getString(qvariant): string = unicode(qvariant.toString()) return string +def convertString(string): + return QVariant(string) + def getStringList(qvariant): string_list = [unicode(string) for string in qvariant.toStringList()] return string_list +def convertStringList(string_list): + return QVariant(string_list) + def getStringDict(qvariant): dict_str_str = {} for key, value in qvariant.toMap().items(): dict_str_str[unicode(key)] = unicode(value.toString()) return dict_str_str +def convertStringDict(string_dict): + result_dict = {} + for key, value in string_dict.items(): + result_dict[QString(key)] = QVariant(value) + return QVariant(result_dict) + def getBool(qvariant): return qvariant.toBool() +def convertBool(boolean): + return QVariant(boolean) + def getDict(qvariant): dict_str_variant = {} for key, value in qvariant.toMap().items(): dict_str_variant[unicode(key)] = value - return dict_str_variant \ No newline at end of file + return dict_str_variant + +def convertDict(dict_str_variant): + result_dict = {} + for key, value in dict_str_variant.items(): + result_dict[QString(key)] = QVariant(value) + return result_dict \ No newline at end of file -- 2.25.1