@@ -61,6 +61,12 int PythonQt::_uniqueModuleCount = 0; | |||||
61 | void PythonQt_init_QtGuiBuiltin(PyObject*); |
|
61 | void PythonQt_init_QtGuiBuiltin(PyObject*); | |
62 | void PythonQt_init_QtCoreBuiltin(PyObject*); |
|
62 | void PythonQt_init_QtCoreBuiltin(PyObject*); | |
63 |
|
63 | |||
|
64 | ||||
|
65 | PyObject* PythonQtConvertFromStringRef(const void* inObject, int /*metaTypeId*/) | |||
|
66 | { | |||
|
67 | return PythonQtConv::QStringToPyObject(((QStringRef*)inObject)->toString()); | |||
|
68 | } | |||
|
69 | ||||
64 | void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) |
|
70 | void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) | |
65 | { |
|
71 | { | |
66 | if (!_self) { |
|
72 | if (!_self) { | |
@@ -69,6 +75,9 void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) | |||||
69 | PythonQtMethodInfo::addParameterTypeAlias("QObjectList", "QList<QObject*>"); |
|
75 | PythonQtMethodInfo::addParameterTypeAlias("QObjectList", "QList<QObject*>"); | |
70 | qRegisterMetaType<QList<QObject*> >("QList<void*>"); |
|
76 | qRegisterMetaType<QList<QObject*> >("QList<void*>"); | |
71 |
|
77 | |||
|
78 | int stringRefId = qRegisterMetaType<QStringRef>("QStringRef"); | |||
|
79 | PythonQtConv::registerMetaTypeToPythonConverter(stringRefId, PythonQtConvertFromStringRef); | |||
|
80 | ||||
72 | PythonQtRegisterToolClassesTemplateConverter(int); |
|
81 | PythonQtRegisterToolClassesTemplateConverter(int); | |
73 | PythonQtRegisterToolClassesTemplateConverter(float); |
|
82 | PythonQtRegisterToolClassesTemplateConverter(float); | |
74 | PythonQtRegisterToolClassesTemplateConverter(double); |
|
83 | PythonQtRegisterToolClassesTemplateConverter(double); | |
@@ -677,14 +686,20 QVariant PythonQt::evalCode(PyObject* object, PyObject* pycode) { | |||||
677 | QVariant result; |
|
686 | QVariant result; | |
678 | if (pycode) { |
|
687 | if (pycode) { | |
679 | PyObject* dict = NULL; |
|
688 | PyObject* dict = NULL; | |
|
689 | PyObject* globals = NULL; | |||
680 | if (PyModule_Check(object)) { |
|
690 | if (PyModule_Check(object)) { | |
681 | dict = PyModule_GetDict(object); |
|
691 | dict = PyModule_GetDict(object); | |
|
692 | globals = dict; | |||
682 | } else if (PyDict_Check(object)) { |
|
693 | } else if (PyDict_Check(object)) { | |
683 | dict = object; |
|
694 | dict = object; | |
|
695 | globals = dict; | |||
|
696 | } else { | |||
|
697 | dict = PyObject_GetAttrString(object, "__dict__"); | |||
|
698 | globals = PyObject_GetAttrString(PyImport_ImportModule(PyString_AS_STRING(PyObject_GetAttrString(object, "__module__"))),"__dict__"); | |||
684 | } |
|
699 | } | |
685 | PyObject* r = NULL; |
|
700 | PyObject* r = NULL; | |
686 | if (dict) { |
|
701 | if (dict) { | |
687 |
r = PyEval_EvalCode((PyCodeObject*)pycode, |
|
702 | r = PyEval_EvalCode((PyCodeObject*)pycode, globals , dict); | |
688 | } |
|
703 | } | |
689 | if (r) { |
|
704 | if (r) { | |
690 | result = PythonQtConv::PyObjToQVariant(r); |
|
705 | result = PythonQtConv::PyObjToQVariant(r); |
General Comments 0
You need to be logged in to leave comments.
Login now