Skip to content

Commit 68a5d48

Browse files
authored
Register QObjectList type conditionally (#339)
FIX: #338
1 parent f63bee1 commit 68a5d48

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/PythonQt.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName)
121121

122122
PythonQtMethodInfo::addParameterTypeAlias("QObjectList", "QList<QObject*>");
123123
qRegisterMetaType<QList<QObject*>>("QList<void*>");
124-
qRegisterMetaType<QObjectList>("QObjectList");
124+
// QObjectList might already be registered by other modules (e.g. QtScript) or under different type names.
125+
// To avoid conflicts or warnings, only register it if it is currently unknown.
126+
if (QMetaType::type("QObjectList") == QMetaType::UnknownType) {
127+
qRegisterMetaType<QObjectList>("QObjectList");
128+
}
125129
qRegisterMetaType<QList<QObject*>>("QList<QObject*>");
126130
if (QT_POINTER_SIZE == 8) {
127131
qRegisterMetaType<quint64>("size_t");

0 commit comments

Comments
 (0)