Skip to content

Commit 25219b8

Browse files
committed
chore: Simplify Qt6 support introducing PythonQtUtils helpers
This change introduces utility functions in PythonQtUtils to simplify and centralize handling differences between Qt5 and Qt6. Suggested-by: mrbean-bremen <[email protected]>
1 parent 920249e commit 25219b8

File tree

5 files changed

+66
-140
lines changed

5 files changed

+66
-140
lines changed

src/PythonQtClassInfo.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ void PythonQtClassInfo::setupCPPObject(const QByteArray& classname)
102102
{
103103
_isQObject = false;
104104
_wrappedClassName = classname;
105-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
106-
_metaTypeId = QMetaType::fromName(classname).id();
107-
#else
108-
_metaTypeId = QMetaType::type(classname);
109-
#endif
105+
_metaTypeId = PythonQtUtils::metaTypeIdFromTypeName(classname);
110106
if (_metaTypeId == 0) {
111107
_metaTypeId = -1;
112108
}

src/PythonQtConversion.cpp

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,7 @@ PyObject* PythonQtConv::convertQtValueToPythonInternal(int type, const void* dat
270270
default:
271271
// check if we have a QList of pointers, which we can circumvent with a QList<void*>
272272
if (info.isQList && (info.innerNamePointerCount == 1)) {
273-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
274-
static int id = QMetaType::fromName("QList<void*>").id();
275-
#else
276-
static int id = QMetaType::type("QList<void*>");
277-
#endif
273+
static int id = PythonQtUtils::metaTypeIdFromTypeName("QList<void*>");
278274
PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID(frame, id, ptr);
279275
// return the constData pointer that will be filled with the result value later on
280276
ptr = (void*)((QVariant*)ptr)->constData();
@@ -315,17 +311,10 @@ void* PythonQtConv::handlePythonToQtAutoConversion(int typeId, PyObject* obj, vo
315311
{
316312
void* ptr = alreadyAllocatedCPPObject;
317313

318-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
319-
static int penId = QMetaType::fromName("QPen").id();
320-
static int brushId = QMetaType::fromName("QBrush").id();
321-
static int cursorId = QMetaType::fromName("QCursor").id();
322-
static int colorId = QMetaType::fromName("QColor").id();
323-
#else
324-
static int penId = QMetaType::type("QPen");
325-
static int brushId = QMetaType::type("QBrush");
326-
static int cursorId = QMetaType::type("QCursor");
327-
static int colorId = QMetaType::type("QColor");
328-
#endif
314+
static int penId = PythonQtUtils::metaTypeIdFromTypeName("QPen");
315+
static int brushId = PythonQtUtils::metaTypeIdFromTypeName("QBrush");
316+
static int cursorId = PythonQtUtils::metaTypeIdFromTypeName("QCursor");
317+
static int colorId = PythonQtUtils::metaTypeIdFromTypeName("QColor");
329318
static PyObject* qtGlobalColorEnum = PythonQtClassInfo::findEnumWrapper("Qt::GlobalColor", nullptr);
330319
if (typeId == cursorId) {
331320
static PyObject* qtCursorShapeEnum = PythonQtClassInfo::findEnumWrapper("Qt::CursorShape", nullptr);
@@ -739,11 +728,7 @@ void* PythonQtConv::ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& i
739728
if (info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) {
740729
// check for QList<AnyPtr*> case, where we will use a QList<void*> QVariant
741730
if (info.isQList && (info.innerNamePointerCount == 1)) {
742-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
743-
static int id = QMetaType::fromName("QList<void*>").id();
744-
#else
745-
static int id = QMetaType::type("QList<void*>");
746-
#endif
731+
static int id = PythonQtUtils::metaTypeIdFromTypeName("QList<void*>");
747732
if (!alreadyAllocatedCPPObject) {
748733
PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID_IF_NEEDED(alreadyAllocatedCPPObject, frame, id, ptr);
749734
ptr = (void*)((QVariant*)ptr)->constData();
@@ -1335,11 +1320,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type)
13351320
// Try to convert the object to a QVariant based on the typeName
13361321
bool ok;
13371322
bool isPtr = false;
1338-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
1339-
QByteArray typeName = QMetaType(type).name();
1340-
#else
1341-
QByteArray typeName = QMetaType::typeName(type);
1342-
#endif
1323+
QByteArray typeName = QByteArray(PythonQtUtils::typeNameFromMetaTypeId(type));
13431324
if (typeName.endsWith("*")) {
13441325
isPtr = true;
13451326
typeName.truncate(typeName.length() - 1);
@@ -1617,17 +1598,13 @@ PyObject* PythonQtConv::createCopyFromMetaType( int type, const void* data )
16171598
// if the type is known, we can construct it via QMetaType::construct
16181599
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
16191600
void* newCPPObject = QMetaType(type).create(data);
1620-
// XXX this could be optimized by using metatypeid directly
1621-
PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(newCPPObject, QMetaType(type).name());
16221601
#elif QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
16231602
void* newCPPObject = QMetaType::create(type, data);
1624-
// XXX this could be optimized by using metatypeid directly
1625-
PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(newCPPObject, QMetaType::typeName(type));
16261603
#else
16271604
void* newCPPObject = QMetaType::construct(type, data);
1628-
// XXX this could be optimized by using metatypeid directly
1629-
PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(newCPPObject, QMetaType::typeName(type));
16301605
#endif
1606+
// XXX this could be optimized by using metatypeid directly
1607+
PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(newCPPObject, QByteArray(PythonQtUtils::typeNameFromMetaTypeId(type)));
16311608
wrap->_ownedByPythonQt = true;
16321609
wrap->_useQMetaTypeDestroy = true;
16331610
return (PyObject*)wrap;

src/PythonQtConversion.h

Lines changed: 34 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,13 @@ template<class ListType, class T>
237237
PyObject* PythonQtConvertListOfValueTypeToPythonList(const void* /*QList<T>* */ inList, int metaTypeId)
238238
{
239239
ListType* list = (ListType*)inList;
240+
static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
240241
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
241-
static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QMetaType(metaTypeId).name());
242242
if (innerType == QMetaType::UnknownType) {
243-
std::cerr << "PythonQtConvertListOfValueTypeToPythonList: unknown inner type " << QMetaType(metaTypeId).name() << std::endl;
244243
#else
245-
static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(QMetaType::typeName(metaTypeId)));
246244
if (innerType == QVariant::Invalid) {
247-
std::cerr << "PythonQtConvertListOfValueTypeToPythonList: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
248245
#endif
246+
std::cerr << "PythonQtConvertListOfValueTypeToPythonList: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
249247
}
250248
PyObject* result = PyTuple_New(list->size());
251249
int i = 0;
@@ -260,15 +258,13 @@ template<class ListType, class T>
260258
bool PythonQtConvertPythonListToListOfValueType(PyObject* obj, void* /*QList<T>* */ outList, int metaTypeId, bool /*strict*/)
261259
{
262260
ListType* list = (ListType*)outList;
261+
static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
263262
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
264-
static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QMetaType(metaTypeId).name());
265263
if (innerType == QMetaType::UnknownType) {
266-
std::cerr << "PythonQtConvertPythonListToListOfValueType: unknown inner type " << QMetaType(metaTypeId).name() << std::endl;
267264
#else
268-
static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(QMetaType::typeName(metaTypeId)));
269265
if (innerType == QVariant::Invalid) {
270-
std::cerr << "PythonQtConvertPythonListToListOfValueType: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
271266
#endif
267+
std::cerr << "PythonQtConvertPythonListToListOfValueType: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
272268
}
273269
bool result = false;
274270
if (PySequence_Check(obj)) {
@@ -299,17 +295,10 @@ template<class ListType, class T>
299295
PyObject* PythonQtConvertListOfKnownClassToPythonList(const void* /*QList<T>* */ inList, int metaTypeId)
300296
{
301297
ListType* list = (ListType*)inList;
302-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
303-
static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo(PythonQtMethodInfo::getInnerListTypeName(QMetaType(metaTypeId).name()));
304-
if (innerType == nullptr) {
305-
std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for " << QMetaType(metaTypeId).name() << std::endl;
306-
}
307-
#else
308-
static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo(PythonQtMethodInfo::getInnerListTypeName(QByteArray(QMetaType::typeName(metaTypeId))));
298+
static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo(PythonQtMethodInfo::getInnerListTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))));
309299
if (innerType == nullptr) {
310-
std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for " << QMetaType::typeName(metaTypeId) << std::endl;
300+
std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
311301
}
312-
#endif
313302
PyObject* result = PyTuple_New(list->size());
314303
int i = 0;
315304
Q_FOREACH(const T& value, *list) {
@@ -326,17 +315,10 @@ template<class ListType, class T>
326315
bool PythonQtConvertPythonListToListOfKnownClass(PyObject* obj, void* /*QList<T>* */ outList, int metaTypeId, bool /*strict*/)
327316
{
328317
ListType* list = (ListType*)outList;
329-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
330-
static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo(PythonQtMethodInfo::getInnerListTypeName(QMetaType(metaTypeId).name()));
318+
static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo(PythonQtMethodInfo::getInnerListTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))));
331319
if (innerType == nullptr) {
332-
std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for " << QMetaType(metaTypeId).name() << std::endl;
320+
std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
333321
}
334-
#else
335-
static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo(PythonQtMethodInfo::getInnerListTypeName(QByteArray(QMetaType::typeName(metaTypeId))));
336-
if (innerType == nullptr) {
337-
std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for " << QMetaType::typeName(metaTypeId) << std::endl;
338-
}
339-
#endif
340322
bool result = false;
341323
if (PySequence_Check(obj)) {
342324
int count = PySequence_Size(obj);
@@ -376,27 +358,18 @@ PyObject* PythonQtConvertPairToPython(const void* /*QPair<T1,T2>* */ inPair, int
376358
static int innerType1 = -1;
377359
static int innerType2 = -1;
378360
if (innerType1==-1) {
379-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
380-
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QMetaType(metaTypeId).name());
361+
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
381362
QList<QByteArray> names = innerTypes.split(',');
382-
innerType1 = QMetaType::fromName(names.at(0).trimmed()).id();
383-
innerType2 = QMetaType::fromName(names.at(1).trimmed()).id();
384-
#else
385-
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(QMetaType::typeName(metaTypeId)));
386-
QList<QByteArray> names = innerTypes.split(',');
387-
innerType1 = QMetaType::type(names.at(0).trimmed());
388-
innerType2 = QMetaType::type(names.at(1).trimmed());
389-
#endif
363+
innerType1 = PythonQtUtils::metaTypeIdFromTypeName(names.at(0).trimmed());
364+
innerType2 = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed());
390365
}
391366
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
392367
if (innerType1 == QMetaType::UnknownType || innerType2 == QMetaType::UnknownType) {
393-
std::cerr << "PythonQtConvertPairToPython: unknown inner type " << QMetaType(metaTypeId).name() << std::endl;
394-
}
395368
#else
396369
if (innerType1 == QVariant::Invalid || innerType2 == QVariant::Invalid) {
397-
std::cerr << "PythonQtConvertPairToPython: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
398-
}
399370
#endif
371+
std::cerr << "PythonQtConvertPairToPython: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
372+
}
400373
PyObject* result = PyTuple_New(2);
401374
PyTuple_SET_ITEM(result, 0, PythonQtConv::convertQtValueToPythonInternal(innerType1, &pair->first));
402375
PyTuple_SET_ITEM(result, 1, PythonQtConv::convertQtValueToPythonInternal(innerType2, &pair->second));
@@ -410,27 +383,18 @@ bool PythonQtConvertPythonToPair(PyObject* obj, void* /*QPair<T1,T2>* */ outPair
410383
static int innerType1 = -1;
411384
static int innerType2 = -1;
412385
if (innerType1 == -1) {
413-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
414-
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QMetaType(metaTypeId).name());
415-
QList<QByteArray> names = innerTypes.split(',');
416-
innerType1 = QMetaType::fromName(names.at(0).trimmed()).id();
417-
innerType2 = QMetaType::fromName(names.at(1).trimmed()).id();
418-
#else
419-
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(QMetaType::typeName(metaTypeId)));
386+
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
420387
QList<QByteArray> names = innerTypes.split(',');
421-
innerType1 = QMetaType::type(names.at(0).trimmed());
422-
innerType2 = QMetaType::type(names.at(1).trimmed());
423-
#endif
388+
innerType1 = PythonQtUtils::metaTypeIdFromTypeName(names.at(0).trimmed());
389+
innerType2 = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed());
424390
}
425391
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
426392
if (innerType1 == QMetaType::UnknownType || innerType2 == QMetaType::UnknownType) {
427-
std::cerr << "PythonQtConvertPythonToPair: unknown inner type " << QMetaType(metaTypeId).name() << std::endl;
428-
}
429393
#else
430394
if (innerType1 == QVariant::Invalid || innerType2 == QVariant::Invalid) {
431-
std::cerr << "PythonQtConvertPythonToPair: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
432-
}
433395
#endif
396+
std::cerr << "PythonQtConvertPythonToPair: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
397+
}
434398
bool result = false;
435399
if (PySequence_Check(obj)) {
436400
int count = PySequence_Size(obj);
@@ -468,17 +432,14 @@ template<class ListType, class T1, class T2>
468432
PyObject* PythonQtConvertListOfPairToPythonList(const void* /*QList<QPair<T1,T2> >* */ inList, int metaTypeId)
469433
{
470434
ListType* list = (ListType*)inList;
435+
static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
471436
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
472-
static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QMetaType(metaTypeId).name());
473437
if (innerType == QMetaType::UnknownType) {
474-
std::cerr << "PythonQtConvertListOfPairToPythonList: unknown inner type " << QMetaType(metaTypeId).name() << std::endl;
475-
}
476438
#else
477-
static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(QMetaType::typeName(metaTypeId)));
478439
if (innerType == QVariant::Invalid) {
479-
std::cerr << "PythonQtConvertListOfPairToPythonList: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
480-
}
481440
#endif
441+
std::cerr << "PythonQtConvertListOfPairToPythonList: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
442+
}
482443
PyObject* result = PyTuple_New(list->size());
483444
int i = 0;
484445
typedef const QPair<T1, T2> Pair;
@@ -494,17 +455,14 @@ template<class ListType, class T1, class T2>
494455
bool PythonQtConvertPythonListToListOfPair(PyObject* obj, void* /*QList<QPair<T1,T2> >* */ outList, int metaTypeId, bool /*strict*/)
495456
{
496457
ListType* list = (ListType*)outList;
458+
static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
497459
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
498-
static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QMetaType(metaTypeId).name());
499460
if (innerType == QMetaType::UnknownType) {
500-
std::cerr << "PythonQtConvertPythonListToListOfPair: unknown inner type " << QMetaType(metaTypeId).name() << std::endl;
501-
}
502461
#else
503-
static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(QMetaType::typeName(metaTypeId)));
504462
if (innerType == QVariant::Invalid) {
505-
std::cerr << "PythonQtConvertPythonListToListOfPair: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
506-
}
507463
#endif
464+
std::cerr << "PythonQtConvertPythonListToListOfPair: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
465+
}
508466
bool result = false;
509467
if (PySequence_Check(obj)) {
510468
int count = PySequence_Size(obj);
@@ -536,23 +494,17 @@ PyObject* PythonQtConvertIntegerMapToPython(const void* /*QMap<int, T>* */ inMap
536494
MapType* map = (MapType*)inMap;
537495
static int innerType = -1;
538496
if (innerType == -1) {
539-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
540-
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QMetaType(metaTypeId).name());
497+
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
541498
QList<QByteArray> names = innerTypes.split(',');
542-
innerType = QMetaType::fromName(names.at(1).trimmed()).id();
499+
innerType = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed());
543500
}
501+
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
544502
if (innerType == QMetaType::UnknownType) {
545-
std::cerr << "PythonQtConvertIntegerMapToPython: unknown inner type " << QMetaType(metaTypeId).name() << std::endl;
546-
}
547503
#else
548-
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(QMetaType::typeName(metaTypeId)));
549-
QList<QByteArray> names = innerTypes.split(',');
550-
innerType = QMetaType::type(names.at(1).trimmed());
551-
}
552504
if (innerType == QVariant::Invalid) {
553-
std::cerr << "PythonQtConvertIntegerMapToPython: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
554-
}
555505
#endif
506+
std::cerr << "PythonQtConvertIntegerMapToPython: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
507+
}
556508

557509
PyObject* result = PyDict_New();
558510
typename MapType::const_iterator t = map->constBegin();
@@ -574,23 +526,17 @@ bool PythonQtConvertPythonToIntegerMap(PyObject* val, void* /*QMap<int, T>* */ o
574526
MapType* map = (MapType*)outMap;
575527
static int innerType = -1;
576528
if (innerType == -1) {
577-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
578-
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QMetaType(metaTypeId).name());
529+
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
579530
QList<QByteArray> names = innerTypes.split(',');
580-
innerType = QMetaType::fromName(names.at(1).trimmed()).id();
531+
innerType = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed());
581532
}
533+
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
582534
if (innerType == QMetaType::UnknownType) {
583-
std::cerr << "PythonQtConvertPythonToIntegerMap: unknown inner type " << QMetaType(metaTypeId).name() << std::endl;
584-
}
585535
#else
586-
QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(QMetaType::typeName(metaTypeId)));
587-
QList<QByteArray> names = innerTypes.split(',');
588-
innerType = QMetaType::type(names.at(1).trimmed());
589-
}
590536
if (innerType == QVariant::Invalid) {
591-
std::cerr << "PythonQtConvertPythonToIntegerMap: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
592-
}
593537
#endif
538+
std::cerr << "PythonQtConvertPythonToIntegerMap: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
539+
}
594540
bool result = false;
595541
if (PyMapping_Check(val)) {
596542
result = true;

0 commit comments

Comments
 (0)