From 3706622525261e10c4f8eaeecd977de7e455b8f5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 21 Jan 2022 17:11:18 +0100 Subject: PySide6: Add __repr__ to QEvents Add a basic __repr__ function to QEvent that shows the type enumeration value. For QtGui, use the debug operator from qevent.h for the relevant events. Add a generic template for using QDebug with module name. [ChangeLog][PySide6] __repr__ functions for some QEvent-derived classes were added. Task-number: PYSIDE-1788 Pick-to: 6.2 Change-Id: I02aca4c98cf3ebd69558103c7d23660d1eb840fb Reviewed-by: Cristian Maureira-Fredes --- .../PySide6/QtCore/typesystem_core_common.xml | 4 + .../PySide6/QtGui/typesystem_gui_common.xml | 108 ++++++++++++++++++--- sources/pyside6/PySide6/glue/qtcore.cpp | 6 ++ sources/pyside6/PySide6/templates/core_common.xml | 12 +++ 4 files changed, 119 insertions(+), 11 deletions(-) diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index f25385d7f..4f04d38af 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -2541,6 +2541,10 @@ + + + diff --git a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml index 4ba90f58d..4c5a794ea 100644 --- a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml +++ b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml @@ -1390,20 +1390,49 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + @@ -1415,35 +1444,75 @@ + + + + + - + + + + + + + - + + + + + + + - + + + + + + + - + + + + + + + - + + + + + + + + + + + + @@ -1456,12 +1525,23 @@ + + + + + - + + + + + + + @@ -2366,7 +2446,13 @@ - + + + + + + + diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp index 85d30053f..5452e9f7f 100644 --- a/sources/pyside6/PySide6/glue/qtcore.cpp +++ b/sources/pyside6/PySide6/glue/qtcore.cpp @@ -1560,3 +1560,9 @@ Py_INCREF(callable); %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(cppCallback); %PYARG_0 = %CONVERTTOPYTHON[int](cppResult); // @snippet qthreadpool-trystart + +// @snippet repr-qevent +QString result; +QDebug(&result).nospace() << "type() << ")>"; +%PYARG_0 = Shiboken::String::fromCString(qPrintable(result)); +// @snippet repr-qevent diff --git a/sources/pyside6/PySide6/templates/core_common.xml b/sources/pyside6/PySide6/templates/core_common.xml index e26771461..d289f7665 100644 --- a/sources/pyside6/PySide6/templates/core_common.xml +++ b/sources/pyside6/PySide6/templates/core_common.xml @@ -249,6 +249,18 @@ %PYARG_0 = Shiboken::String::fromCString(qPrintable(format)); + + + +