PythonQt
Classes | Macros | Typedefs | Functions
PythonQtConversion.h File Reference
#include "PythonQtPythonInclude.h"
#include "PythonQt.h"
#include "PythonQtMisc.h"
#include "PythonQtClassInfo.h"
#include "PythonQtMethodInfo.h"
#include <QList>
#include <vector>

Go to the source code of this file.

Classes

class  PythonQtConv
 a static class that offers methods for type conversion More...
 

Macros

#define PythonQtRegisterListTemplateConverter(type, innertype)
 
#define PythonQtRegisterListTemplateConverterForKnownClass(type, innertype)
 
#define PythonQtRegisterQPairConverter(type1, type2)
 
#define PythonQtRegisterIntegerMapConverter(type, innertype)
 
#define PythonQtRegisterListTemplateQPairConverter(listtype, type1, type2)
 
#define PythonQtRegisterToolClassesTemplateConverter(innertype)
 
#define PythonQtRegisterToolClassesTemplateConverterForKnownClass(innertype)
 

Typedefs

typedef PyObjectPythonQtConvertMetaTypeToPythonCB(const void *inObject, int metaTypeId)
 
typedef bool PythonQtConvertPythonToMetaTypeCB(PyObject *inObject, void *outObject, int metaTypeId, bool strict)
 
typedef QVariant PythonQtConvertPythonSequenceToQVariantListCB(PyObject *inObject)
 

Functions

template<class ListType , class T >
PyObjectPythonQtConvertListOfValueTypeToPythonList (const void *inList, int metaTypeId)
 
template<class ListType , class T >
bool PythonQtConvertPythonListToListOfValueType (PyObject *obj, void *outList, int metaTypeId, bool)
 
template<class ListType , class T >
PyObjectPythonQtConvertListOfKnownClassToPythonList (const void *inList, int metaTypeId)
 
template<class ListType , class T >
bool PythonQtConvertPythonListToListOfKnownClass (PyObject *obj, void *outList, int metaTypeId, bool)
 
template<class T1 , class T2 >
PyObjectPythonQtConvertPairToPython (const void *inPair, int metaTypeId)
 
template<class T1 , class T2 >
bool PythonQtConvertPythonToPair (PyObject *obj, void *outPair, int metaTypeId, bool)
 
template<class ListType , class T1 , class T2 >
PyObjectPythonQtConvertListOfPairToPythonList (const void *inList, int metaTypeId)
 
template<class ListType , class T1 , class T2 >
bool PythonQtConvertPythonListToListOfPair (PyObject *obj, void *outList, int metaTypeId, bool)
 
template<class MapType , class T >
PyObjectPythonQtConvertIntegerMapToPython (const void *inMap, int metaTypeId)
 
template<class MapType , class T >
bool PythonQtConvertPythonToIntegerMap (PyObject *val, void *outMap, int metaTypeId, bool)
 

Detailed Description

Author
Florian Link
Last changed by
Author
florian
Date
2006-05

Definition in file PythonQtConversion.h.

Macro Definition Documentation

◆ PythonQtRegisterIntegerMapConverter

#define PythonQtRegisterIntegerMapConverter (   type,
  innertype 
)
Value:
{ \
int typeId = qRegisterMetaType<type<int, innertype>>(#type "<int, " #innertype ">"); \
PythonQtConv::registerPythonToMetaTypeConverter(typeId, \
PythonQtConv::registerMetaTypeToPythonConverter(typeId, \
}
PyObject * PythonQtConvertPairToPython(const void *inPair, int metaTypeId)
PyObject * PythonQtConvertIntegerMapToPython(const void *inMap, int metaTypeId)
bool PythonQtConvertPythonToIntegerMap(PyObject *val, void *outMap, int metaTypeId, bool)

Definition at line 83 of file PythonQtConversion.h.

84 { \
85 int typeId = qRegisterMetaType<type<int, innertype>>(#type "<int, " #innertype ">"); \
86 PythonQtConv::registerPythonToMetaTypeConverter(typeId, \
88 PythonQtConv::registerMetaTypeToPythonConverter(typeId, \
90 }

◆ PythonQtRegisterListTemplateConverter

#define PythonQtRegisterListTemplateConverter (   type,
  innertype 
)
Value:
{ \
int typeId = qRegisterMetaType<type<innertype>>(#type "<" #innertype ">"); \
PythonQtConv::registerPythonToMetaTypeConverter(typeId, \
PythonQtConv::registerMetaTypeToPythonConverter(typeId, \
}
PyObject * PythonQtConvertListOfValueTypeToPythonList(const void *inList, int metaTypeId)
bool PythonQtConvertPythonListToListOfValueType(PyObject *obj, void *outList, int metaTypeId, bool)

Definition at line 58 of file PythonQtConversion.h.

59 { \
60 int typeId = qRegisterMetaType<type<innertype>>(#type "<" #innertype ">"); \
61 PythonQtConv::registerPythonToMetaTypeConverter(typeId, \
63 PythonQtConv::registerMetaTypeToPythonConverter(typeId, \
65 }

◆ PythonQtRegisterListTemplateConverterForKnownClass

#define PythonQtRegisterListTemplateConverterForKnownClass (   type,
  innertype 
)
Value:
{ \
int typeId = qRegisterMetaType<type<innertype>>(#type "<" #innertype ">"); \
PythonQtConv::registerPythonToMetaTypeConverter(typeId, \
PythonQtConv::registerMetaTypeToPythonConverter(typeId, \
}
bool PythonQtConvertPythonListToListOfKnownClass(PyObject *obj, void *outList, int metaTypeId, bool)
PyObject * PythonQtConvertListOfKnownClassToPythonList(const void *inList, int metaTypeId)

Definition at line 67 of file PythonQtConversion.h.

68 { \
69 int typeId = qRegisterMetaType<type<innertype>>(#type "<" #innertype ">"); \
70 PythonQtConv::registerPythonToMetaTypeConverter(typeId, \
72 PythonQtConv::registerMetaTypeToPythonConverter(typeId, \
74 }

◆ PythonQtRegisterListTemplateQPairConverter

#define PythonQtRegisterListTemplateQPairConverter (   listtype,
  type1,
  type2 
)
Value:
{ \
int typeId = qRegisterMetaType<listtype<QPair<type1, type2>>>(#listtype "<QPair<" #type1 "," #type2 ">>"); \
PythonQtConv::registerPythonToMetaTypeConverter(typeId, \
PythonQtConv::registerMetaTypeToPythonConverter(typeId, \
}
bool PythonQtConvertPythonListToListOfPair(PyObject *obj, void *outList, int metaTypeId, bool)
PyObject * PythonQtConvertListOfPairToPythonList(const void *inList, int metaTypeId)

Definition at line 92 of file PythonQtConversion.h.

93 { \
95 int typeId = qRegisterMetaType<listtype<QPair<type1, type2>>>(#listtype "<QPair<" #type1 "," #type2 ">>"); \
96 PythonQtConv::registerPythonToMetaTypeConverter(typeId, \
98 PythonQtConv::registerMetaTypeToPythonConverter(typeId, \
100 }

◆ PythonQtRegisterQPairConverter

#define PythonQtRegisterQPairConverter (   type1,
  type2 
)
Value:
{ \
int typeId = qRegisterMetaType<QPair<type1, type2>>("QPair<" #type1 "," #type2 ">"); \
PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonToPair<type1, type2>); \
PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertPairToPython<type1, type2>); \
}

Definition at line 76 of file PythonQtConversion.h.

77 { \
78 int typeId = qRegisterMetaType<QPair<type1, type2>>("QPair<" #type1 "," #type2 ">"); \
79 PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonToPair<type1, type2>); \
80 PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertPairToPython<type1, type2>); \
81 }

◆ PythonQtRegisterToolClassesTemplateConverter

#define PythonQtRegisterToolClassesTemplateConverter (   innertype)

◆ PythonQtRegisterToolClassesTemplateConverterForKnownClass

#define PythonQtRegisterToolClassesTemplateConverterForKnownClass (   innertype)

Typedef Documentation

◆ PythonQtConvertMetaTypeToPythonCB

typedef PyObject * PythonQtConvertMetaTypeToPythonCB(const void *inObject, int metaTypeId)

Definition at line 54 of file PythonQtConversion.h.

◆ PythonQtConvertPythonSequenceToQVariantListCB

typedef QVariant PythonQtConvertPythonSequenceToQVariantListCB(PyObject *inObject)

Definition at line 56 of file PythonQtConversion.h.

◆ PythonQtConvertPythonToMetaTypeCB

typedef bool PythonQtConvertPythonToMetaTypeCB(PyObject *inObject, void *outObject, int metaTypeId, bool strict)

Definition at line 55 of file PythonQtConversion.h.

Function Documentation

◆ PythonQtConvertIntegerMapToPython()

template<class MapType , class T >
PyObject * PythonQtConvertIntegerMapToPython ( const void inMap,
int  metaTypeId 
)

Definition at line 524 of file PythonQtConversion.h.

525{
527 static int innerType = -1;
528 if (innerType == -1) {
533 }
534 if (innerType == QMetaType::UnknownType) {
535 std::cerr << "PythonQtConvertIntegerMapToPython: unknown inner type "
536 << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
537 }
538
540 typename MapType::const_iterator t = map->constBegin();
541 PyObject* key;
542 PyObject* val;
543 for (; t != map->constEnd(); t++) {
544 key = PyLong_FromLong(t.key());
547 Py_DECREF(key);
548 Py_DECREF(val);
549 }
550 return result;
551}
struct _object PyObject
static PyObject * convertQtValueToPythonInternal(int type, const void *data)
converts the Qt parameter given in data, interpreting it as a type registered qvariant/meta type,...
static QByteArray getInnerTemplateTypeName(const QByteArray &typeName)
returns the inner type name of a simple template of the form SomeObject<InnerType>
const char * typeNameFromMetaTypeId(int metaTypeId)
Returns the type name from a meta type ID.
int metaTypeIdFromTypeName(const QByteArray &className)
Returns the meta type ID from a type name.

References PythonQtConv::convertQtValueToPythonInternal(), PythonQtMethodInfo::getInnerTemplateTypeName(), PythonQtUtils::metaTypeIdFromTypeName(), PythonQtConvertPairToPython(), and PythonQtUtils::typeNameFromMetaTypeId().

◆ PythonQtConvertListOfKnownClassToPythonList()

template<class ListType , class T >
PyObject * PythonQtConvertListOfKnownClassToPythonList ( const void inList,
int  metaTypeId 
)

Definition at line 328 of file PythonQtConversion.h.

329{
333 if (innerType == nullptr) {
334 std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for "
335 << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
336 }
337 PyObject* result = PyTuple_New(list->size());
338 int i = 0;
339 for (const T& value : *list) {
340 T* newObject = new T(value);
343 wrap->_ownedByPythonQt = true;
345 i++;
346 }
347 return result;
348}
a class that stores all required information about a Qt object (and an optional associated C++ class ...
static QByteArray getInnerListTypeName(const QByteArray &typeName)
returns the inner type name of a simple template or the typename without appended "List".
PyObject * wrapPtr(void *ptr, const QByteArray &name, bool passOwnership=false)
PythonQtClassInfo * getClassInfo(const QMetaObject *meta)
get the class info for a meta object (if available)
static PythonQtPrivate * priv()
get access to internal data (should not be used on the public API, but is used by some C functions)
Definition PythonQt.h:572
a Python wrapper object for Qt objects and C++ objects (that are themselves wrapped by wrapper QObjec...
bool _ownedByPythonQt
flag that stores if the object is owned by pythonQt

References PythonQtInstanceWrapper::_ownedByPythonQt, PythonQtClassInfo::className(), PythonQtPrivate::getClassInfo(), PythonQtMethodInfo::getInnerListTypeName(), PythonQt::priv(), PythonQtUtils::typeNameFromMetaTypeId(), and PythonQtPrivate::wrapPtr().

◆ PythonQtConvertListOfPairToPythonList()

template<class ListType , class T1 , class T2 >
PyObject * PythonQtConvertListOfPairToPythonList ( const void inList,
int  metaTypeId 
)

Definition at line 467 of file PythonQtConversion.h.

468{
470 static int innerType =
472 if (innerType == QMetaType::UnknownType) {
473 std::cerr << "PythonQtConvertListOfPairToPythonList: unknown inner type "
474 << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
475 }
476 PyObject* result = PyTuple_New(list->size());
477 int i = 0;
478 typedef const QPair<T1, T2> Pair;
479 for (Pair& value : *list) {
481 PyTuple_SET_ITEM(result, i, object);
482 i++;
483 }
484 return result;
485}
static int getInnerTemplateMetaType(const QByteArray &typeName)
returns the inner type id of a simple template of the form SomeObject<InnerType>

References PythonQtMethodInfo::getInnerTemplateMetaType(), PythonQtConvertPairToPython(), and PythonQtUtils::typeNameFromMetaTypeId().

◆ PythonQtConvertListOfValueTypeToPythonList()

template<class ListType , class T >
PyObject * PythonQtConvertListOfValueTypeToPythonList ( const void inList,
int  metaTypeId 
)

Definition at line 273 of file PythonQtConversion.h.

274{
276 static const int innerType =
278 if (innerType == QMetaType::UnknownType) {
279 std::cerr << "PythonQtConvertListOfValueTypeToPythonList: unknown inner type "
280 << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
281 }
282 PyObject* result = PyTuple_New(list->size());
283 int i = 0;
284 for (const T& value : *list) {
286 i++;
287 }
288 return result;
289}

References PythonQtConv::convertQtValueToPythonInternal(), PythonQtMethodInfo::getInnerTemplateMetaType(), and PythonQtUtils::typeNameFromMetaTypeId().

◆ PythonQtConvertPairToPython()

template<class T1 , class T2 >
PyObject * PythonQtConvertPairToPython ( const void *  inPair,
int  metaTypeId 
)

Definition at line 394 of file PythonQtConversion.h.

395{
397 static int innerType1 = -1;
398 static int innerType2 = -1;
399 if (innerType1 == -1) {
405 }
406 if (innerType1 == QMetaType::UnknownType || innerType2 == QMetaType::UnknownType) {
407 std::cerr << "PythonQtConvertPairToPython: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)
408 << std::endl;
409 }
413 return result;
414}

References PythonQtConv::convertQtValueToPythonInternal(), PythonQtMethodInfo::getInnerTemplateTypeName(), PythonQtUtils::metaTypeIdFromTypeName(), and PythonQtUtils::typeNameFromMetaTypeId().

Referenced by PythonQtInstanceWrapper::classInfo(), PythonQtWrapper_QMetaObject::classInfo(), PythonQtWrapper_QMetaObject::classInfoCount(), PythonQtWrapper_QMetaObject::classInfoOffset(), PythonQtStdDecorators::connect(), PythonQtWrapper_QMetaObject::constructor(), PythonQtWrapper_QMetaObject::constructorCount(), PythonQtInstanceWrapper::dynamicClassInfo(), PythonQtWrapper_QMetaObject::enumerator(), PythonQtWrapper_QMetaObject::enumeratorCount(), PythonQtWrapper_QMetaObject::enumeratorOffset(), PythonQtArgumentFrame::establishPersistentPtr(), PythonQtArgumentFrame::establishPersistentViewPtr(), PythonQtWrapper_QMetaObject::getClassName(), PythonQtWrapper_QMetaObject::indexOfClassInfo(), PythonQtWrapper_QMetaObject::indexOfConstructor(), PythonQtWrapper_QMetaObject::indexOfEnumerator(), PythonQtWrapper_QMetaObject::indexOfMethod(), PythonQtWrapper_QMetaObject::indexOfProperty(), PythonQtWrapper_QMetaObject::indexOfSignal(), PythonQtWrapper_QMetaObject::indexOfSlot(), PythonQtUtils::isPythonClassType(), PythonQtWrapper_QMetaObject::method(), PythonQtWrapper_QMetaObject::methodCount(), PythonQtUtils::methodName(), PythonQtWrapper_QMetaObject::methodOffset(), PythonQtObjectPtr::operator!=(), PythonQtSafeObjectPtr::operator!=(), PythonQtObjectPtr::operator!=(), PythonQtSafeObjectPtr::operator!=(), PythonQtObjectPtr::operator=(), PythonQtSafeObjectPtr::operator=(), PythonQtSafeObjectPtr::operator=(), PythonQtObjectPtr::operator=(), PythonQtObjectPtr::operator=(), PythonQtSafeObjectPtr::operator=(), PythonQtSafeObjectPtr::operator=(), PythonQtObjectPtr::operator=(), PythonQtSafeObjectPtr::operator=(), PythonQtObjectPtr::operator==(), PythonQtSafeObjectPtr::operator==(), PythonQtObjectPtr::operator==(), PythonQtSafeObjectPtr::operator==(), PythonQtInstanceWrapper::passOwnershipToCPP(), PythonQtInstanceWrapper::passOwnershipToPython(), PythonQtWrapper_QMetaObject::property(), PythonQtWrapper_QMetaObject::propertyCount(), PythonQtWrapper_QMetaObject::propertyOffset(), PythonQtConvertIntegerMapToPython(), PythonQtConvertListOfPairToPythonList(), PythonQtConvertPythonListToListOfPair(), PythonQtConvertPythonToIntegerMap(), PythonQtMethodInfo::PythonQtMethodInfo(), PythonQtObjectPtr::PythonQtObjectPtr(), PythonQtObjectPtr::PythonQtObjectPtr(), PythonQtSafeObjectPtr::PythonQtSafeObjectPtr(), PythonQtSafeObjectPtr::PythonQtSafeObjectPtr(), PythonQtSafeObjectPtr::PythonQtSafeObjectPtr(), PythonQtSignalTarget::PythonQtSignalTarget(), PythonQtSlotInfo::PythonQtSlotInfo(), PythonQtSlotInfo::PythonQtSlotInfo(), PythonQtThreadStateSaver::restore(), PythonQtThreadStateSaver::save(), PythonQtSlotInfo::setNextInfo(), PythonQtUtils::signature(), PythonQtWrapper_QMetaObject::static_QMetaObject_checkConnectArgs(), PythonQtStdDecorators::static_QObject_connect(), PythonQtStdDecorators::static_QObject_connect(), PythonQtStdDecorators::static_QObject_disconnect(), PythonQtStdDecorators::static_QObject_disconnect(), PythonQtStdDecorators::static_Qt_qAbs(), PythonQtStdDecorators::static_Qt_qBound(), PythonQtStdDecorators::static_Qt_qCritical(), PythonQtStdDecorators::static_Qt_qDebug(), PythonQtStdDecorators::static_Qt_qFatal(), PythonQtStdDecorators::static_Qt_qFuzzyCompare(), PythonQtStdDecorators::static_Qt_qMax(), PythonQtStdDecorators::static_Qt_qMin(), PythonQtStdDecorators::static_Qt_qrand(), PythonQtStdDecorators::static_Qt_qRound(), PythonQtStdDecorators::static_Qt_qRound64(), PythonQtStdDecorators::static_Qt_qsrand(), PythonQtStdDecorators::static_Qt_qVersion(), PythonQtStdDecorators::static_Qt_qWarning(), PythonQtStdDecorators::static_Qt_SIGNAL(), PythonQtStdDecorators::static_Qt_SLOT(), PythonQtWrapper_QMetaObject::superClass(), PythonQtObjectPtr::takeObject(), PythonQtSafeObjectPtr::takeObject(), PythonQtUtils::typeName(), PythonQtUtils::typeNameFromMetaTypeId(), and PythonQtWrapper_QMetaObject::userProperty().

◆ PythonQtConvertPythonListToListOfKnownClass()

template<class ListType , class T >
bool PythonQtConvertPythonListToListOfKnownClass ( PyObject obj,
void outList,
int  metaTypeId,
bool   
)

Definition at line 351 of file PythonQtConversion.h.

353{
357 if (innerType == nullptr) {
358 std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for "
359 << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
360 }
361 bool result = false;
362 if (PySequence_Check(obj)) {
364 if (count >= 0) {
365 result = true;
367 for (int i = 0; i < count; i++) {
371 bool ok;
372 T* object = (T*)PythonQtConv::castWrapperTo(wrap, innerType->className(), ok);
374 if (ok) {
375 list->push_back(*object);
376 } else {
377 result = false;
378 break;
379 }
380 } else {
382 result = false;
383 break;
384 }
385 }
386 }
387 }
388 return result;
389}
PYTHONQT_EXPORT PyTypeObject PythonQtInstanceWrapper_Type
static void * castWrapperTo(PythonQtInstanceWrapper *wrapper, const QByteArray &className, bool &ok)
cast wrapper to given className if possible

References PythonQtConv::castWrapperTo(), PythonQtClassInfo::className(), PythonQtPrivate::getClassInfo(), PythonQtMethodInfo::getInnerListTypeName(), PythonQt::priv(), PythonQtInstanceWrapper_Type, and PythonQtUtils::typeNameFromMetaTypeId().

◆ PythonQtConvertPythonListToListOfPair()

template<class ListType , class T1 , class T2 >
bool PythonQtConvertPythonListToListOfPair ( PyObject obj,
void outList,
int  metaTypeId,
bool   
)

Definition at line 488 of file PythonQtConversion.h.

490{
492 static int innerType =
494 if (innerType == QMetaType::UnknownType) {
495 std::cerr << "PythonQtConvertPythonListToListOfPair: unknown inner type "
496 << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
497 }
498 bool result = false;
499 if (PySequence_Check(obj)) {
501 if (count >= 0) {
502 result = true;
504 for (int i = 0; i < count; i++) {
509 list->push_back(pair);
510 } else {
512 result = false;
513 break;
514 }
515 }
516 }
517 }
518 return result;
519}

References PythonQtMethodInfo::getInnerTemplateMetaType(), PythonQtConvertPairToPython(), and PythonQtUtils::typeNameFromMetaTypeId().

◆ PythonQtConvertPythonListToListOfValueType()

template<class ListType , class T >
bool PythonQtConvertPythonListToListOfValueType ( PyObject obj,
void outList,
int  metaTypeId,
bool   
)

Definition at line 292 of file PythonQtConversion.h.

294{
296 static const int innerType =
298 if (innerType == QMetaType::UnknownType) {
299 std::cerr << "PythonQtConvertPythonListToListOfValueType: unknown inner type "
300 << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
301 }
302 bool result = false;
303 if (PySequence_Check(obj)) {
305 if (count >= 0) {
306 result = true;
308 for (int i = 0; i < count; i++) {
310 // this is quite some overhead, but it avoids having another large switch...
313 if (v.isValid()) {
314 list->push_back(qvariant_cast<T>(v));
315 } else {
316 result = false;
317 break;
318 }
319 }
320 }
321 }
322 return result;
323}
static QVariant PyObjToQVariant(PyObject *val, int type=-1)

References PythonQtMethodInfo::getInnerTemplateMetaType(), PythonQtConv::PyObjToQVariant(), and PythonQtUtils::typeNameFromMetaTypeId().

◆ PythonQtConvertPythonToIntegerMap()

template<class MapType , class T >
bool PythonQtConvertPythonToIntegerMap ( PyObject val,
void outMap,
int  metaTypeId,
bool   
)

Definition at line 554 of file PythonQtConversion.h.

555{
557 static int innerType = -1;
558 if (innerType == -1) {
563 }
564 if (innerType == QMetaType::UnknownType) {
565 std::cerr << "PythonQtConvertPythonToIntegerMap: unknown inner type "
566 << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
567 }
568 bool result = false;
569 if (PyMapping_Check(val)) {
570 result = true;
572 if (items) {
573 int count = PyList_Size(items);
575 PyObject* key;
577 for (int i = 0; i < count; i++) {
581
582 bool ok;
583 int intKey = PythonQtConv::PyObjGetInt(key, false, ok);
584 // this is quite some overhead, but it avoids having another large switch...
586 if (v.isValid() && ok) {
587 map->insert(intKey, qvariant_cast<T>(v));
588 } else {
589 result = false;
590 break;
591 }
592 }
594 }
595 }
596 return result;
597}
static int PyObjGetInt(PyObject *val, bool strict, bool &ok)
get int from py object

References PythonQtMethodInfo::getInnerTemplateTypeName(), PythonQtUtils::metaTypeIdFromTypeName(), PythonQtConv::PyObjGetInt(), PythonQtConv::PyObjToQVariant(), PythonQtConvertPairToPython(), and PythonQtUtils::typeNameFromMetaTypeId().

◆ PythonQtConvertPythonToPair()

template<class T1 , class T2 >
bool PythonQtConvertPythonToPair ( PyObject obj,
void outPair,
int  metaTypeId,
bool   
)

Definition at line 417 of file PythonQtConversion.h.

418{
420 static int innerType1 = -1;
421 static int innerType2 = -1;
422 if (innerType1 == -1) {
428 }
429 if (innerType1 == QMetaType::UnknownType || innerType2 == QMetaType::UnknownType) {
430 std::cerr << "PythonQtConvertPythonToPair: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)
431 << std::endl;
432 }
433 bool result = false;
434 if (PySequence_Check(obj)) {
436 if (count == 2) {
437 result = true;
439
441 // this is quite some overhead, but it avoids having another large switch...
444 if (v.isValid()) {
445 pair->first = qvariant_cast<T1>(v);
446 } else {
447 return false;
448 }
449
451 // this is quite some overhead, but it avoids having another large switch...
454 if (v.isValid()) {
455 pair->second = qvariant_cast<T2>(v);
456 } else {
457 return false;
458 }
459 }
460 }
461 return result;
462}

References PythonQtMethodInfo::getInnerTemplateTypeName(), PythonQtUtils::metaTypeIdFromTypeName(), PythonQtConv::PyObjToQVariant(), and PythonQtUtils::typeNameFromMetaTypeId().