|
52 | 52 |
|
53 | 53 | typedef PyObject* PythonQtConvertMetaTypeToPythonCB(const void* inObject, int metaTypeId); |
54 | 54 | typedef bool PythonQtConvertPythonToMetaTypeCB(PyObject* inObject, void* outObject, int metaTypeId, bool strict); |
| 55 | +typedef QVariant PythonQtConvertPythonSequenceToQVariantListCB(PyObject* inObject); |
55 | 56 |
|
56 | 57 | #define PythonQtRegisterListTemplateConverter(type, innertype) \ |
57 | 58 | { int typeId = qRegisterMetaType<type<innertype > >(#type"<"#innertype">"); \ |
@@ -164,6 +165,10 @@ class PYTHONQT_EXPORT PythonQtConv { |
164 | 165 | //! register a converter callback from cpp to python for given metatype |
165 | 166 | static void registerMetaTypeToPythonConverter(int metaTypeId, PythonQtConvertMetaTypeToPythonCB* cb) { _metaTypeToPythonConverters.insert(metaTypeId, cb); } |
166 | 167 |
|
| 168 | + //! set a callback that is called when a Python sequence should be converted to a QVariantList |
| 169 | + //! to allow special conversion. |
| 170 | + static void setPythonSequenceToQVariantListCallback(PythonQtConvertPythonSequenceToQVariantListCB* cb) { _pythonSequenceToQVariantListCB = cb; } |
| 171 | + |
167 | 172 | //! converts the Qt parameter given in \c data, interpreting it as a \c type registered qvariant/meta type, into a Python object, |
168 | 173 | static PyObject* convertQtValueToPythonInternal(int type, const void* data); |
169 | 174 |
|
@@ -194,6 +199,7 @@ class PYTHONQT_EXPORT PythonQtConv { |
194 | 199 | protected: |
195 | 200 | static QHash<int, PythonQtConvertMetaTypeToPythonCB*> _metaTypeToPythonConverters; |
196 | 201 | static QHash<int, PythonQtConvertPythonToMetaTypeCB*> _pythonToMetaTypeConverters; |
| 202 | + static PythonQtConvertPythonSequenceToQVariantListCB* _pythonSequenceToQVariantListCB; |
197 | 203 |
|
198 | 204 | //! handle automatic conversion of some special types (QColor, QBrush, ...) |
199 | 205 | static void* handlePythonToQtAutoConversion(int typeId, PyObject* obj, void* alreadyAllocatedCPPObject); |
|
0 commit comments